예제 #1
0
    public static ListView <Material> GetFadeMaterials(GameObject go)
    {
        if (go == null)
        {
            return(null);
        }
        Renderer[] componentsInChildren = go.GetComponentsInChildren <Renderer>();
        if (componentsInChildren == null || componentsInChildren.Length == 0)
        {
            return(null);
        }
        ListView <Material> listView = new ListView <Material>();

        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            Renderer renderer = componentsInChildren[i];
            if (renderer != null && renderer.sharedMaterial != null)
            {
                if (renderer.sharedMaterial.HasProperty("_FadeFactor"))
                {
                    listView.Add(renderer.material);
                }
                else
                {
                    Shader fadeShader = FadeMaterialUtility.GetFadeShader(renderer.sharedMaterial.shader, true);
                    if (fadeShader != null)
                    {
                        renderer.material.shader = fadeShader;
                        listView.Add(renderer.material);
                    }
                }
            }
        }
        return((listView.get_Count() <= 0) ? null : listView);
    }
예제 #2
0
 public override void Leave(Action _action, Track _track)
 {
     if (this.materials != null)
     {
         float num = !this.FadeIn ? 0f : 1f;
         num = Mathf.Clamp01(num);
         for (int i = 0; i < this.materials.Count; i++)
         {
             Material material = this.materials[i];
             material.SetFloat("_FadeFactor", num);
             if (this.FadeIn)
             {
                 Shader fadeShader = FadeMaterialUtility.GetFadeShader(material.shader, false);
                 if ((fadeShader != null) && (fadeShader != material.shader))
                 {
                     material.shader = fadeShader;
                 }
             }
         }
         this.materials = null;
     }
 }
예제 #3
0
        public override void Leave(Action _action, Track _track)
        {
            if (this.materials == null)
            {
                return;
            }
            float value = (!this.FadeIn) ? 0f : 1f;

            value = Mathf.Clamp01(value);
            for (int i = 0; i < this.materials.get_Count(); i++)
            {
                Material material = this.materials.get_Item(i);
                material.SetFloat("_FadeFactor", value);
                if (this.FadeIn)
                {
                    Shader fadeShader = FadeMaterialUtility.GetFadeShader(material.shader, false);
                    if (fadeShader != null && fadeShader != material.shader)
                    {
                        material.shader = fadeShader;
                    }
                }
            }
            this.materials = null;
        }