Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Button colors not rendering on certain Macs (standalone)

Discussion in 'General Graphics' started by EnduvoJD, May 12, 2022.

  1. EnduvoJD

    EnduvoJD

    Joined:
    Aug 12, 2016
    Posts:
    49
    We have a gradient shader used on our custom buttons. The button background image is changed at runtime by our custom button script. We flip between a UI shader and the gradient shader. We set the colors of the gradient shader at runtime (setColor("_Color1", color) etc...). We load the colors from a ScriptableObject.

    I've add the gradient shader to the Always Included assets.

    We have 3 different Macs that I've tried the standalone build on, and the buttons are rendering properly on one of them. Checking Unity Diagnostics, all 3 devices are running the same OS version (Monterey 12.3.1), same graphics API (Metal), and same version of the graphics API (16). The noticeable difference is the GPU. The working one is using the Iris Graphics. The other 2 are AMD and Apple M1.

    The button colors are rendered properly on my Mac (AMD gpu) in the Editor, but not in the standalone build. I checked my Editor logs and it's also using the AMD gpu there.

    Any thoughts?
     
    Last edited: May 12, 2022
  2. EnduvoJD

    EnduvoJD

    Joined:
    Aug 12, 2016
    Posts:
    49
    Ok, figured it out. The issue was with the materials being used. I had to use the following for Z test in the shaders.

    ZTest [unity_GUIZTestMode]
     
  3. EnduvoJD

    EnduvoJD

    Joined:
    Aug 12, 2016
    Posts:
    49
    Something similar is also happening to my TextMeshProUGUI text.

    After I've switched back and forth between different panels in my UI, all the text components on the panels are gone, though the images in the same gameobjects are shown. I would assume something related to Z tests for the materials or masks.
     
  4. EnduvoJD

    EnduvoJD

    Joined:
    Aug 12, 2016
    Posts:
    49
    If anyone has ideas how I could get these same issues to happen in the Editor, that would be great.
     
  5. EnduvoJD

    EnduvoJD

    Joined:
    Aug 12, 2016
    Posts:
    49
    Ok, figured out some of the second issue as well. One of the pages was temporarily using a camera in order to render some textures. It appears that camera rendering caused TMP text using a certain material to disappear afterwards. I haven't noticed any obvious differences in that font material causing it though.
     
    Last edited: May 13, 2022
  6. EnduvoJD

    EnduvoJD

    Joined:
    Aug 12, 2016
    Posts:
    49
  7. EnduvoJD

    EnduvoJD

    Joined:
    Aug 12, 2016
    Posts:
    49
    The issue of disappearing text was due to using the same TMP material preset on screen UI and in world space. Enabling the world space object is what triggered it.

    Solved by duplicating the TMP font asset and using separate materials for 2D and 3D text.