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

Question What's Up With This UI Image?

Discussion in 'Editor & General Support' started by Drakkith, Aug 22, 2023.

  1. Drakkith

    Drakkith

    Joined:
    Nov 29, 2016
    Posts:
    57
    Why is this UI image completely black? And why can I see the editor grid lines through it?
    I just starting working with uGUI and I'm thoroughly confused. Things sometimes look wildly different depending on if I open the prefab from the asset section of the project window, open it from the hierarchy window, or if the wind in Kansas scares a groundhog back into its hole.

    Screenshot 2023-08-22 00.24.32.png
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    At a glance, you have set the UI image's colour to be completely black.
     
    Drakkith and CodeSmile like this.
  3. Drakkith

    Drakkith

    Joined:
    Nov 29, 2016
    Posts:
    57
    Thanks. Setting the color to white seems to have fixed the issue with the image being all black, but it's still semi-transparent, as I can still see the grid lines behind it. Any ideas?
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Turn off the grid then. ;)

    The grid is always drawn on top in the scene view.
     
    Drakkith likes this.
  5. Drakkith

    Drakkith

    Joined:
    Nov 29, 2016
    Posts:
    57
    Ah, I had no idea. Well, then I guess everything is okay! Thanks all!
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    You're always gonna have all kinds of horrible things happen if you set ANY PART of your scale to zero.

    Screen Shot 2023-08-23 at 6.56.30 AM.png

    Just... don't do that.

    The proper way to set scales:

    https://forum.unity.com/threads/onpointerenter-loose-image.1152686/#post-7396073

    NEVER set scale (or any part of scale) to zero or negative.

    NEVER use Vector2 because that makes the third term (Z) zero.

    ALWAYS use Vector3, and make sure that the .z is either 1.0f, or else your non-zero scale.

    Similarly never set scale to Vector3.zero, especially in a UI, because this will cause layout divide-by-zeros and damage all your hierarchy.
     
    Drakkith likes this.
  7. Drakkith

    Drakkith

    Joined:
    Nov 29, 2016
    Posts:
    57
    Thank you!