NGUI与特效的层级关系

通过调整特效的 render queue 来解决特效与NGUI界面之间的层级关系问题,用以下脚本解决:

using System.Collections.Generic;
using UnityEngine; public class UIRenderQueueSorter : MonoBehaviour
{
[SerializeField]
UIWidget m_source;
[SerializeField]
int m_offset;
[SerializeField]
List<Renderer> m_renderers = new List<Renderer>(); public void Initialize()
{
Renderer[] renders = transform.GetComponentsInChildren<Renderer>(true);
m_renderers.AddRange(renders);
} void Update()
{
if (m_source && m_renderers.Count > )
{
for (int i = ; i < m_renderers.Count; i++)
{
Renderer r = m_renderers[i];
if (r && r.sharedMaterial && m_source.drawCall != null)
r.sharedMaterial.renderQueue = m_source.drawCall.renderQueue + m_offset;
}
}
} public void AddRenderer(Renderer r)
{
if (!m_renderers.Contains(r))
{
m_renderers.Add(r);
}
} public void ClearAllRenderers()
{
m_renderers.Clear();
} public UIWidget Source
{
set { m_source = value; }
} public int Offset
{
set { m_offset = value; }
}
}
上一篇:NET 下载共享文件


下一篇:gene框架文档 - 概述