示例#1
0
 public void GetRenderEffects(ref RenderEffectsOut effects)
 {
     if (m_TookDamage > 0)
     {
         effects.m_Color = Color.yellow;
     }
     effects.m_Priority = 2;
 }
示例#2
0
        public void UpdateEffects()
        {
            var reouts = new List <RenderEffectsOut>();

            foreach (var ire in m_RenderEffects)
            {
                var reo = new RenderEffectsOut();
                ire.GetRenderEffects(ref reo);
                reouts.Add(reo);
            }

            var finalReout = new RenderEffectsOut();

            finalReout.m_Color   = Color.white;
            finalReout.m_Visible = true;
            foreach (var renderer in GameObjectExt.GetComponentsInSelfOrChildren <Renderer>(gameObject))
            {
                finalReout.m_Renderers.Add(renderer);
            }

            reouts.Sort((x, y) => x.m_Priority.CompareTo(y.m_Priority));

            foreach (var reo in reouts)
            {
                if (reo.m_Color.HasValue)
                {
                    finalReout.m_Color = reo.m_Color;
                }
                if (reo.m_Visible.HasValue)
                {
                    finalReout.m_Visible = reo.m_Visible;
                }
                foreach (var renderer in reo.m_Renderers)
                {
                    finalReout.m_Renderers.Add(renderer);
                }
            }

            {
                foreach (var renderer in finalReout.m_Renderers)
                {
                    Material mat = renderer.material;

                    Color finalColor = finalReout.m_Color.Value;
                    //bool renderEnabled = finalReout.m_Visible.Value;

                    mat.SetColor("_Color", finalColor);
                    //renderer.enabled = renderEnabled;
                }
            }
        }