예제 #1
0
 public override void Render(StringBuilder sb)
 {
     AddProperty("DEF", DEF);
     AddProperty("Name", Name);
     AddProperty("skyBox", SkyBox);
     AddProperty("groundColor", Vector3.ToString(GroundColor));
     AddProperty("skyColor", Vector3.ToString(SkyColor));
     AddProperty("slm:lightingColor", LightingColor);
     if (LightingMode != LightingMode.NotSet)
     {
         AddProperty("slm:lightingSource", LightingMode.ToString());
     }
     if (ReflectionMode != ReflectionMode.NotSet)
     {
         AddProperty("slm:reflectionMode", ReflectionMode.ToString());
     }
     base.Render(sb);
 }
예제 #2
0
        private void UpdateShaderInternal()
        {
            foreach (var localRenderer in gameObject.GetComponentsInChildren <Renderer>())
            {
                localRenderer.enabled = Enabled;
                if (!Enabled)
                {
                    continue;
                }

                var transparent = Visibility.ToString("f");
                var colorBy     = _colorBy.ToString("f");
                var lit         = _lit.ToString("f");
                var side        = _side.ToString("f");

                var materials = localRenderer.sharedMaterials;

                if (Visibility == VisibilityMode.Disabled)
                {
                    localRenderer.enabled = false;
                }
                else
                {
                    // Object switches have precedence in enabling / disabling the renderer
                    var switchBase = GetComponentInParent <ObjectSwitchBase>();
                    if (switchBase)
                    {
                        switchBase.SetActiveChild(switchBase.ActiveChild);
                    }
                    else
                    {
                        localRenderer.enabled = true;
                    }

                    if (materials.Length == 0)
                    {
                        materials = new Material[1];
                    }
                    if (materials.Length != 2 && _side == SideMode.TwoSided)
                    {
                        materials = new Material[2];
                    }

                    switch (materials.Length)
                    {
                    case 1:
                        var matName = transparent + colorBy + lit + side;
                        var mat     = Resources.Load("Materials/" + matName, typeof(Material)) as Material;
                        if (mat == null)
                        {
                            Debug.LogWarning(gameObject.name + ": Material " + matName + " not found.");
                        }
                        materials[0] = mat;
                        break;

                    case 2:
                        var matNameFront = transparent + colorBy + lit + SideMode.Front.ToString("f");
                        var matNameBack  = transparent + colorBy + lit + SideMode.Back.ToString("f");
                        var matFront     = Resources.Load("Materials/" + matNameFront, typeof(Material)) as Material;
                        var matBack      = Resources.Load("Materials/" + matNameBack, typeof(Material)) as Material;
                        materials[0] = matFront;
                        materials[1] = matBack;
                        if (Side != SideMode.TwoSided)
                        {
                            var newMaterials = new Material[1];
                            if (Side == SideMode.Front)
                            {
                                newMaterials[0] = materials[0];
                            }
                            else
                            {
                                newMaterials[0] = materials[1];
                            }

                            materials = newMaterials;
                        }
                        break;
                    }
                }
                if (Application.isPlaying)
                {
                    localRenderer.materials = materials;
                }
                else
                {
                    localRenderer.sharedMaterials = materials;
                }
                _materials = materials;
            }
        }