Unity3D NGUI特效层级问题

using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class NguiEftSort : MonoBehaviour
{
public UIWidget basewidget;
public int rendererOffset = 0;
public bool runOnce = false;

void Update()
{
    Renderer r =GetComponent<Renderer>();

    if (basewidget == null)
    {
        basewidget = GetComponent<UIWidget>();
    }

    if (basewidget != null && basewidget.drawCall != null && r != null)
    {
        int targetQ = basewidget.drawCall.renderQueue + rendererOffset;
        if (targetQ > 0)
        {
            r.sharedMaterial.renderQueue = targetQ;
        }
    }
    if (runOnce && Application.isPlaying)
    {
        this.enabled = false;
    }
}

}

使用:将目标层级的UIWidget复制到basesidget上,设置redererOffset的偏移值即可。

猜你喜欢

转载自blog.csdn.net/qq_18192161/article/details/80053450