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. Dismiss Notice

Display GameObject on Hover? [SOLVED]

Discussion in 'UGUI & TextMesh Pro' started by radler470, Jan 14, 2015.

  1. radler470

    radler470

    Joined:
    Dec 3, 2014
    Posts:
    86
    I am creating a Start menu for my game, and I am wondering if there is a way I can display a Text object when hovering over a UI Button? If so, how would I go about doing this?

    Much appreciated.
     
  2. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    1.) Add Event Trigger to UI Component
    2.) Click Add New
    3.) Add PointerEnter
    4.) Drag the UI Text and set the function for SetActive and pass true

    Expand upon this and add also the PointerExit to deactivate it aswell if this is what you are aiming for.

    Hope this helps.
     
    radler470 likes this.
  3. radler470

    radler470

    Joined:
    Dec 3, 2014
    Posts:
    86
    This is really helpful, thank you. I am very new to this, but what do you mean by "pass true?" That's the only part I am stuck on. Thank you!

    edit: Just because the dropdown gives me the GameObject.SetAvtive(bool) option - how do I set that to true?
     
  4. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    A Toggle should pop up check the box for "True" leave it unchecked for "False"
     
    radler470 likes this.
  5. radler470

    radler470

    Joined:
    Dec 3, 2014
    Posts:
    86
    Oh, that's the check box. Totally works. Thank you!!!
     
    Polymorphik likes this.
  6. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Glad it helped :)
     
    radler470 likes this.
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You can also do this via script by implementing the various interfaces on your own MonoBehaviour.
     
  8. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Yeah you could or just use what Unity UI team has already built. I think its much easier and possibly more optimized. But hey to each his own.
     
  9. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Optimisation is identical, or better. This is the same method Unity uses inside the EventTrigger. Its just a matter of preference.

    The EventSystem is very powerful, and has been somewhat overlooked in the UI hype.