14
2017
[Shader] Draw World Space UI Always On Top
If you want to draw UI in VR (for example Google Cardboard), it doesn’t support ScreenSpace rendermode in canvas..
So all the UI’s are using WorldSpace RenderMode.. which causes issues when UI goes behind geometry.
Fix: You can modify UI shader to disable ZTest
Shader source: (tested with 5.6.0b3)
https://github.com/UnityCommunity/UnityLibrary/blob/master/Assets/Shaders/2D/UI/UI_Always_On_Top.shader
*Only one line was modified from original UI shader,
// From
ZTest [unity_GUIZTestMode]
// To
ZTest Off
Related Posts
6 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
Just when I need it ! Thank you 🙂
I’ve put it on all “Image” and “Text” components of my UI. Is there a way to replace the default UI shader by this one ?
Yes, i believe if you rename the shader as: Shader “UI/Default”
then it might override the built-in one..
so I just added this to my project, I didn’t even attach it to anything and it fixed the shadow on top of my world space ui problem I was having.
Don’t understand how thats possible. But Im just gonna go with it.
I cannot find the shader.
Fixed link now
Thanks mate!