ControlParticle 处理粒子特效 和 ngui 显示层级问题

作者:雨辰 发布于:2015-7-17 20:41 Friday 分类:Unity3D

处理粒子特效 和 ngui 显示层级问题
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ControlParticle : MonoBehaviour
{
    public int renderQueue = 3300;
    public bool runOnlyOnce = false;
    public bool affectChildren = false;

    private Renderer[] renderers;
    void Awake()
    {
        if (affectChildren)
            renderers = this.gameObject.GetComponentsInChildren<Renderer>();
        else
            renderers = this.gameObject.GetComponents<Renderer>();

        Update();
    }
    void Update()
    {
        foreach (Renderer renderer in renderers)
        {
            if (renderer != null && renderer.sharedMaterial != null)
            {
                renderer.sharedMaterial.renderQueue = renderQueue;
            }
        }
        if (runOnlyOnce && Application.isPlaying)
        {
            this.enabled = false;
        }
    }
}

 

标签: Unity3D

发表评论:

雨辰 joyimp|@2011-2018 京ICP备16030765号