Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Noob_Hide Layer via Button Click or Hide by Tag Name

Discussion in 'Scripting' started by troy_halsey, Jun 8, 2015.

  1. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    63
    Hi-

    I know this is a newbie question, but I have searched the forums and can't find an answer that makes sense or works.

    I have info bubbles over objects (via canvas buttons)...all tagged "InfoBubble"..

    I have a GUI button that says, Hide Info Bubbles...

    When the user clicks this button, I need an array to find all objects tagged InfoBubble and set them to disable.

    I have tried writing the script and dragging it to the buttons onClick parameters, but I either getting errors with the code or nothing happens. I am super new to coding and so frustrated I still cant write the simplest of code.

    Could someone please explain how to do this as though I was dropped as a child? No offense to anyone who was actually dropped as a child.

    Working in C#

    Thank you,

    Troy
     
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,256
    The script can be on anything really. Dragging it to the onClick should give you error messages, its not the type of component it is looking for. It wants the GameObject that has the script attached. I suggest watching the UI tutorials to help you. The one on UI event and event triggers will show you more about how that part works.
     
  3. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    63
    Thanks Chris,

    But how do I have the button call the script? I will watch the tutorials again, just didn't click the first time. Very slow learner.

    Thanks