示例#1
0
 private void OnDestroy()
 {
     GraphicsUtils.ReleaseRenderTexture(this._renderTexture);
 }
示例#2
0
 protected virtual void CreateDistortionMap(int w, int h)
 {
     this.distortionMap = GraphicsUtils.GetRenderTexture(w / 2, h / 2, this.DistortionMapDepthBit, this.DistortionMapFormat);
 }
示例#3
0
 private void SetupFaders()
 {
     Renderer[] componentsInChildren = base.GetComponentsInChildren <Renderer>();
     this._faders = new List <IAlphaFader>();
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         Renderer renderer = componentsInChildren[i];
         if (renderer is ParticleSystemRenderer)
         {
             GraphicsUtils.CreateAndAssignInstancedMaterial(renderer, renderer.sharedMaterial);
             if (this.FadeTintColor && renderer.sharedMaterial.HasProperty("_TintColor"))
             {
                 this._faders.Add(new ColorSharedMaterialFader(renderer, "_TintColor"));
             }
             if (this.FadeEmissionColor && renderer.sharedMaterial.HasProperty("_EmissionColor"))
             {
                 this._faders.Add(new ColorSharedMaterialFader(renderer, "_EmissionColor"));
             }
             if (this.FadeMainAlpha && renderer.sharedMaterial.HasProperty("_MainAlpha"))
             {
                 this._faders.Add(new FloatSharedMaterialFader(renderer, "_MainAlpha"));
             }
             if (this.FadeOutlineAlpha && renderer.sharedMaterial.HasProperty("_OutlineAlpha"))
             {
                 this._faders.Add(new FloatSharedMaterialFader(renderer, "_OutlineAlpha"));
             }
             if (this.FadeMainColor && renderer.sharedMaterial.HasProperty("_Color"))
             {
                 this._faders.Add(new ColorSharedMaterialFader(renderer, "_Color"));
             }
             if (this.FadeOpaqueness && renderer.sharedMaterial.HasProperty("_Opaqueness"))
             {
                 this._faders.Add(new FloatSharedMaterialFader(renderer, "_Opaqueness"));
             }
         }
         else
         {
             if (this.FadeTintColor && renderer.sharedMaterial.HasProperty("_TintColor"))
             {
                 this._faders.Add(new ColorRendererFader(renderer, "_TintColor"));
             }
             if (this.FadeEmissionColor && renderer.sharedMaterial.HasProperty("_EmissionColor"))
             {
                 this._faders.Add(new ColorRendererFader(renderer, "_EmissionColor"));
             }
             if (this.FadeMainAlpha && renderer.sharedMaterial.HasProperty("_MainAlpha"))
             {
                 this._faders.Add(new FloatRendererFader(renderer, "_MainAlpha"));
             }
             if (this.FadeOutlineAlpha && renderer.sharedMaterial.HasProperty("_OutlineAlpha"))
             {
                 this._faders.Add(new FloatRendererFader(renderer, "_OutlineAlpha"));
             }
             if (this.FadeMainColor && renderer.sharedMaterial.HasProperty("_Color"))
             {
                 this._faders.Add(new ColorRendererFader(renderer, "_Color"));
             }
             if (this.FadeOpaqueness && renderer.sharedMaterial.HasProperty("_Opaqueness"))
             {
                 this._faders.Add(new FloatRendererFader(renderer, "_Opaqueness"));
             }
         }
     }
 }
示例#4
0
        public void HandleEffectOverride(MonoEffectOverride effectOverride)
        {
            for (int i = 0; i < this.rendererOverrides.Length; i++)
            {
                Material material;
                RendererMaterialOverride @override = this.rendererOverrides[i];
                if (effectOverride.materialOverrides.TryGetValue(@override.materialOverrideKey, out material))
                {
                    if (@override.renderer is ParticleSystemRenderer)
                    {
                        GraphicsUtils.CreateAndAssignInstancedMaterial(@override.renderer, material);
                    }
                    else
                    {
                        @override.renderer.sharedMaterial = material;
                    }
                }
                else if (@override.renderer is ParticleSystemRenderer)
                {
                    if (GraphicsUtils.IsInstancedMaterial(@override.renderer.sharedMaterial))
                    {
                        GraphicsUtils.CreateAndAssignInstancedMaterial(@override.renderer, @override.originalMaterial);
                    }
                    else
                    {
                        @override.renderer.sharedMaterial = @override.originalMaterial;
                    }
                }
                else
                {
                    @override.renderer.sharedMaterial = @override.originalMaterial;
                }
            }
            for (int j = 0; j < this.effectOverlays.Length; j++)
            {
                string str;
                if (effectOverride.effectOverlays.TryGetValue(this.effectOverlays[j], out str))
                {
                    Singleton <EffectManager> .Instance.TriggerEntityEffectPattern(str, base.transform.position, base.transform.forward, base.transform.localScale, base._effect.owner);
                }
            }
            MaterialPropertyBlock dest = new MaterialPropertyBlock();

            for (int k = 0; k < this.rendererColorOverrides.Length; k++)
            {
                Color color;
                RendererColorOverride override2 = this.rendererColorOverrides[k];
                if (effectOverride.colorOverrides.TryGetValue(override2.colorOverrideKey, out color))
                {
                    if (override2.renderer is ParticleSystemRenderer)
                    {
                        if (!GraphicsUtils.IsInstancedMaterial(override2.renderer.sharedMaterial))
                        {
                            GraphicsUtils.CreateAndAssignInstancedMaterial(override2.renderer, override2.renderer.sharedMaterial);
                        }
                        override2.renderer.sharedMaterial.SetColor(override2.colorPropertyKey, color);
                    }
                    else
                    {
                        dest.Clear();
                        override2.renderer.GetPropertyBlock(dest);
                        dest.SetColor(override2.colorPropertyKey, effectOverride.colorOverrides[override2.colorOverrideKey]);
                        override2.renderer.SetPropertyBlock(dest);
                    }
                }
            }
            for (int m = 0; m < this.rendererFloatOverrides.Length; m++)
            {
                float num5;
                RendererFloatOverride override3 = this.rendererFloatOverrides[m];
                if (effectOverride.floatOverrides.TryGetValue(override3.floatOverrideKey, out num5))
                {
                    if (override3.renderer is ParticleSystemRenderer)
                    {
                        if (!GraphicsUtils.IsInstancedMaterial(override3.renderer.sharedMaterial))
                        {
                            GraphicsUtils.CreateAndAssignInstancedMaterial(override3.renderer, override3.renderer.sharedMaterial);
                        }
                        override3.renderer.sharedMaterial.SetFloat(override3.floatPropertyKey, num5);
                    }
                    else
                    {
                        dest.Clear();
                        override3.renderer.GetPropertyBlock(dest);
                        dest.SetFloat(override3.floatPropertyKey, effectOverride.floatOverrides[override3.floatOverrideKey]);
                        override3.renderer.SetPropertyBlock(dest);
                    }
                }
            }
            for (int n = 0; n < this.particleSystemStartColorOverrides.Length; n++)
            {
                ParticleSystemStartColorOverride override4 = this.particleSystemStartColorOverrides[n];
                if (override4.type == ParticleSystemStartColorOverride.StartColorType.ConstColor1)
                {
                    Color color2;
                    if (effectOverride.colorOverrides.TryGetValue(override4.colorOverrideKey1, out color2))
                    {
                        override4.particleSystem.startColor = color2;
                    }
                }
                else
                {
                    Color color3;
                    Color color4;
                    if (((override4.type == ParticleSystemStartColorOverride.StartColorType.RandomBetweenColor12) && effectOverride.colorOverrides.TryGetValue(override4.colorOverrideKey1, out color3)) && effectOverride.colorOverrides.TryGetValue(override4.colorOverrideKey2, out color4))
                    {
                        override4.particleSystem.startColor = Color.Lerp(color3, color4, UnityEngine.Random.value);
                    }
                }
            }
        }