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

Help with UI GameObjects

Discussion in 'UGUI & TextMesh Pro' started by Skyward_Games, Feb 24, 2020.

  1. Skyward_Games

    Skyward_Games

    Joined:
    Feb 24, 2020
    Posts:
    2
    Hi guys, I'd love if you guys could answer a simple question of mine.
    My game has a Panel and a Text game objects always active for dialogues. Is there any difference between letting the Text gameobject empty and the panel with the Alpha 0 between disabling it completely?
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,835
    Yes, there are several differences, although they might or might not be important in your particular case.

    For one, inactive objects are ignored for purposes of mouse clicks. It's possible you've set up your objects not to be clickable anyway (by turning off the "raycast target" checkboxes on Image and Text components), but if not, they can "block" clicks when they're active (even when transparent) and not when inactive.

    For another, inactive objects won't automatically run magic methods like Update, Start, etc.

    There are some practical differences for animation. You can turn transparency on and off "gradually" so it looks like it fades in or out, but making a GameObject active/inactive is an all-or-nothing deal, so it will just appear or disappear. (Of course, you CAN set transparency in one jump, too; but you don't have to.)


    By the way, rather than setting the panel to be transparent, you should consider adding a "Canvas Group" component, which will let you control the transparency of that object and all its children in one place, so you can make the entire box fade in/out (including any text, buttons, etc. in the dialog). You an also use a Canvas Group to toggle whether or not the whole group can be raycast targets.
     
    Skyward_Games likes this.
  3. Skyward_Games

    Skyward_Games

    Joined:
    Feb 24, 2020
    Posts:
    2
    Thanks!! Actually you've also helped me with my UI haha, I had to create two canvas, one Camera - Render(Not Interactable) and the other Screen Space - Overlay(Interactable) because of that. I'm really trying not to make a mess of this project of mine haha