示例#1
0
        public override void UpdateMaterials()
        {
            var cars = CarLogic.FindObjectsOfType <CarLogic>();

            foreach (var c in cars)
            {
                var renderers = c.GetComponentsInChildren <Renderer>();
                foreach (var r in renderers)
                {
                    foreach (var m in r.materials)
                    {
                        Action <string> foo = (string id) =>
                        {
                            if (m.HasProperty(id))
                            {
                                AddMaterial(m, (Object obj, Color color) =>
                                {
                                    var mat = obj as Material;
                                    if (mat == null)
                                    {
                                        return;
                                    }

                                    mat.SetColor(id, color);
                                }, id);
                            }
                        };

                        foo("_Color");
                        foo("_Color2");
                        foo("_EmitColor");
                        foo("_Emission");
                        foo("_ReflectColor");
                        foo("_SpecColor");
                    }
                }
            }
        }