美文网首页
简单特效前后设置RenderQueue

简单特效前后设置RenderQueue

作者: 张晓强_843d | 来源:发表于2019-10-08 10:15 被阅读0次

    using UnityEngine;

    using System.Collections;

    using FrameBase;

    [ExecuteInEditMode]  

    public class UIEffectQueue: MonoBehaviour

    {

    private  GameObject mBaseWidget;

    public GameObject basewidget {

    set {

    mBaseWidget = value;

    widget = mBaseWidget.GetComponent ();

    if (widget == null)

    GameDebug.GameLogError (gameObject.name + " widget is null!");

    render = GetComponent ();

    }

    get {

    return mBaseWidget;

    }

    }

    public int rendererOffset = 0;

    public bool runOnce = false;

    UIWidget widget;

    Renderer render;

    void Update ()

    {  

    //if (basewidget.GetComponent () != null) {

    //    w = basewidget.GetComponent ();

    //}

    //Renderer r = GetComponent ();

    //if (widget == null)

    //{

    //    widget = GetComponent();  

    //}

    if (widget != null && widget.drawCall != null && render != null) {

    int targetQ = widget.drawCall.renderQueue + rendererOffset;  

    if (targetQ > 0) {

    #if UNITY_EDITOR

                    render.material.renderQueue = targetQ; 

    #else

    render.sharedMaterial.renderQueue = targetQ;   

    #endif

    }  

    }  

    #if UNITY_EDITOR

    if (runOnce && Application.isPlaying) {  

    #else

            if (runOnce ) {  

    #endif

    this.enabled = false;    

    }    

    }

    相关文章

      网友评论

          本文标题:简单特效前后设置RenderQueue

          本文链接:https://www.haomeiwen.com/subject/gezvpctx.html