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

Sprite is covering UI

Discussion in '2D' started by unity_R6B9ZH8FFkHgiQ, Feb 9, 2021.

Thread Status:
Not open for further replies.
  1. unity_R6B9ZH8FFkHgiQ

    unity_R6B9ZH8FFkHgiQ

    Joined:
    Dec 15, 2018
    Posts:
    6
    I have a sprite that is animated by a Shader. When I disable the Shader it goes behind the UI.

    There's a screenshot below displaying the problem
     

    Attached Files:

  2. jleven22

    jleven22

    Joined:
    Mar 26, 2019
    Posts:
    399
    Is this an orthographic project? It looks 3D to me, and I think you're having z-axis issues.
     
  3. unity_R6B9ZH8FFkHgiQ

    unity_R6B9ZH8FFkHgiQ

    Joined:
    Dec 15, 2018
    Posts:
    6
    My game is 2D and my camera is set to orthographic. The sprites don't go in front of the UI when I set the canvas to overlay instead of camera but I want the post-processing to apply to the UI.
     
  4. Kalliber95

    Kalliber95

    Joined:
    Mar 27, 2015
    Posts:
    19
    On your UI game object there should be a canvas component. In the canvas component there is a sorting order option.
    upload_2021-2-10_10-43-25.png

    I'd say crank that up all the way so when it renders out, it renders above any other sprites that share the same z axis.
    The way Unity treats 2D is that everything is on 0 on the z axis so if there are overlapping sprites or in your case UI camera overlay, they will both be trying to render above.
     
  5. unity_R6B9ZH8FFkHgiQ

    unity_R6B9ZH8FFkHgiQ

    Joined:
    Dec 15, 2018
    Posts:
    6
    I put the sort order to max but it doesn't work.
     

    Attached Files:

  6. Kalliber95

    Kalliber95

    Joined:
    Mar 27, 2015
    Posts:
    19
    Hrmm It's hard to say without seeing the project properly. Is the sprite's sorting order being changed via shader or a script or anything?
     
  7. unity_R6B9ZH8FFkHgiQ

    unity_R6B9ZH8FFkHgiQ

    Joined:
    Dec 15, 2018
    Posts:
    6
    The sprites order in layer is always -14. It seems that when ever I remove the shader the sprite using it goes behind the UI. Here's the Shader
     

    Attached Files:

    • oh.png
      oh.png
      File size:
      151.7 KB
      Views:
      319
  8. unity_R6B9ZH8FFkHgiQ

    unity_R6B9ZH8FFkHgiQ

    Joined:
    Dec 15, 2018
    Posts:
    6
    I found a way to solve this problem :D
     
  9. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,343
    You should share the solution
     
    woricek and Uzi_Suicide like this.
  10. SantiSou

    SantiSou

    Joined:
    Jan 30, 2021
    Posts:
    1
    Please
     
  11. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,758
    Please don't necro posts with useless one-word replies. If you have a question, start a new post, it's FREE.

    When you post you must learn to communicate.

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, log output, variable values, and especially any errors you see
    - links to documentation you used to cross-check your work (CRITICAL!!!)

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/
     
Thread Status:
Not open for further replies.