Skip to content

Instantly share code, notes, and snippets.

@x5lcfd
Last active October 17, 2016 02:00
Show Gist options
  • Select an option

  • Save x5lcfd/d567c6fe93786151f42a4209fd319201 to your computer and use it in GitHub Desktop.

Select an option

Save x5lcfd/d567c6fe93786151f42a4209fd319201 to your computer and use it in GitHub Desktop.
NGUIRenderQueue
/*
* This code snippet can adjust the gameobject's renderqueue in NGUI.
*/
using UnityEngine;
[ExecuteInEditMode]
class NGUIParticleRenderQueue : MonoBehaviour
{
public UIPanel panel;
public int rendererQOffset = 3000;
public bool runOnlyOnce = false;
void Update ()
{
Renderer r = renderer;
if ( panel == null )
{
panel = GetComponent<UIPanel>();
}
if ( panel != null && r != null )
{
int targetRenderQueue = panel.startingRenderQueue + rendererQOffset;
if ( targetRenderQueue > 0 )
{
r.sharedMaterial.renderQueue = targetRenderQueue;
}
}
if ( runOnlyOnce && Application.isPlaying )
{
this.enabled = false;
}
}
}
@x5lcfd
Copy link
Copy Markdown
Author

x5lcfd commented Jul 15, 2016

also you can only adjust the render queue

// Just add this line to your code.
r.shaderedMaterial.renderQueue = targetRenderQueue;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment