Last active
October 17, 2016 02:00
-
-
Save x5lcfd/d567c6fe93786151f42a4209fd319201 to your computer and use it in GitHub Desktop.
NGUIRenderQueue
This file contains hidden or 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
| /* | |
| * 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; | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
also you can only adjust the render queue