Skip to content

Instantly share code, notes, and snippets.

@dogles
Created December 17, 2014 14:12
Show Gist options
  • Save dogles/62f7f56b8dc5da45b73f to your computer and use it in GitHub Desktop.
Save dogles/62f7f56b8dc5da45b73f to your computer and use it in GitHub Desktop.
MonoBehaviour for sorting Renderers against NGUI widgets.
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