Created
August 6, 2015 09:40
-
-
Save arun02139/ab5fea17fe8b10d7b816 to your computer and use it in GitHub Desktop.
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; | |
// LINK: http://docs.unity3d.com/Manual/SL-SubshaderTags.html | |
public enum RenderOrderType { None = 0, Background = 1000, Geometry = 2000, PhoenixGround = 2010, PhoenixGroundShadow = 2020, | |
PhoenixEnvironProp = 2030, AlphaTest = 2450, Transparent = 3000, Overlay = 4000 } | |
public class RenderOrder : MonoBehaviour | |
{ | |
public int Order; | |
Material material; | |
void Awake() | |
{ | |
if(GetComponent<Renderer>() != null) | |
material = GetComponent<Renderer>().sharedMaterial; | |
else if(GetComponent<CanvasRenderer>() != null) | |
material = GetComponent<CanvasRenderer>().GetMaterial(); | |
else | |
NUnit.Framework.Assert.Fail(); | |
} | |
void Start() | |
{ | |
if(material != null && Order != 0) | |
{ | |
// Debug.Log(string.Format("Setting {0}'s render order to {1} ({2})", gameObject.name, (RenderOrderType)material.renderQueue, Order)); | |
material.renderQueue = Order; | |
} | |
else | |
{ | |
Debug.Log(string.Format("RenderOrder.Start {0}: m_Material is {1}, Order = {2}", name, material == null ? "null" : "not null", this.Order)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment