Created
December 17, 2014 14:12
-
-
Save dogles/62f7f56b8dc5da45b73f to your computer and use it in GitHub Desktop.
MonoBehaviour for sorting Renderers against NGUI widgets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class UISortBehavior : MonoBehaviour | |
{ | |
public UIWidget widgetInFrontOfMe; | |
[System.NonSerialized] | |
Renderer m_renderer; | |
void Awake() { | |
m_renderer = this.renderer; | |
} | |
void LateUpdate() { | |
if (this.widgetInFrontOfMe != null && this.widgetInFrontOfMe.drawCall != null) { | |
int rq = this.widgetInFrontOfMe.drawCall.renderQueue-1; | |
foreach (Material material in m_renderer.materials) { | |
material.renderQueue = rq; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment