Esempio n. 1
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;
                }
            }
        }
Esempio n. 2
0
        void Update()
        {
            var worldState = WorldState.Instance;

            if (worldState == null)
            {
                return;
            }

            var cam = Camera.main;

            transform.localScale = new Vector3(5.0f, 5.0f, 1.0f);

            float intensity = worldState.SunlightIntensity;

            foreach (var renderer in GameObjectExt.GetComponentsInSelfOrChildren <Renderer>(gameObject))
            {
                Material mat = renderer.material;

                mat.SetColor("_EmissionColor", new Color(intensity, intensity, intensity, 1.0f));
            }
        }