public override void OnAwake()
        {
            base.OnAwake();

            _decalTextureProperty = materialProperties.AddOrGetTextureProperty("_Decal", true);

            _fillEnabledProperty = materialProperties.AddOrGetProperty <MaterialKeywordProperty>("DECAL_FILL");
            _fillColorProperty   = materialProperties.AddOrGetProperty <MaterialColorProperty>("_DecalColor");

            _outlineEnabledProperty = materialProperties.AddOrGetProperty <MaterialKeywordProperty>("DECAL_OUTLINE");
            _outlineColorProperty   = materialProperties.AddOrGetProperty <MaterialColorProperty>("_OutlineColor");
            _outlineWidthProperty   = materialProperties.AddOrGetProperty <MaterialFloatProperty>("_OutlineWidth");
        }
예제 #2
0
 public MaterialPropertyWrapper(MaterialProperty materialProperty)
 {
     if (materialProperty.GetType().Equals(typeof(MaterialFloatProperty)))
     {
         typeIndex     = 0;
         floatProperty = (MaterialFloatProperty)materialProperty;
     }
     else if (materialProperty.GetType().Equals(typeof(MaterialColorProperty)))
     {
         typeIndex     = 1;
         colorProperty = (MaterialColorProperty)materialProperty;
     }
     else if (materialProperty.GetType().Equals(typeof(MaterialVectorProperty)))
     {
         typeIndex      = 2;
         vectorProperty = (MaterialVectorProperty)materialProperty;
     }
     else if (materialProperty.GetType().Equals(typeof(MaterialTextureProperty)))
     {
         typeIndex       = 3;
         textureProperty = (MaterialTextureProperty)materialProperty;
     }
 }
예제 #3
0
        private void InitializeShaderInterface()
        {
            if (m_shaderInterface)
            {
                shaderName = m_shaderInterface.shaderName;

                var shaderDef = UnityClient.UserSession.Instance.m_settings.shaders.FirstOrDefault(s => s.shader.name == shaderName);

                if (shaderDef != null)
                {
                    defaultShader = shaderDef.name;
                }

                foreach (var item in m_shaderInterface.properties)
                {
                    switch (item.type)
                    {
                    case ShaderInterface.ShaderPropertyType.Float:
                    {
                        var floatProp = floats.FirstOrDefault(p => p.name == item.name);

                        if (floatProp == null)
                        {
                            floatProp = new MaterialFloatProperty();
                            floats.Add(floatProp);
                        }

                        JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(item), floatProp);
                        break;
                    }

                    case ShaderInterface.ShaderPropertyType.Range:
                    {
                        var rangeProp = ranges.FirstOrDefault(p => p.name == item.name);

                        if (rangeProp == null)
                        {
                            rangeProp       = new MaterialRangeProperty();
                            rangeProp.value = item.range.def;
                            ranges.Add(rangeProp);
                        }

                        JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(item), rangeProp);
                        break;
                    }

                    case ShaderInterface.ShaderPropertyType.Vector:
                    {
                        var vecProp = vectors.FirstOrDefault(p => p.name == item.name);

                        if (vecProp == null)
                        {
                            vecProp = new MaterialVectorProperty();
                            vectors.Add(vecProp);
                        }
                        JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(item), vecProp);
                        break;
                    }

                    case ShaderInterface.ShaderPropertyType.Color:
                    {
                        var colorProp = colors.FirstOrDefault(p => p.name == item.name);

                        if (colorProp == null)
                        {
                            colorProp = new MaterialColorProperty();

                            if (m_display is SkyboxWidget)
                            {
                                colorProp.value = Color.gray;
                            }

                            colors.Add(colorProp);
                        }

                        JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(item), colorProp);
                        break;
                    }

                    case ShaderInterface.ShaderPropertyType.TexEnv:
                    {
                        var texProp = textures.FirstOrDefault(p => p.name == item.name);

                        if (texProp == null)
                        {
                            texProp = new MaterialTextureProperty();
                            textures.Add(texProp);

                            if (m_display is SkyboxWidget)
                            {
                                texProp.wrapMode = TextureWrapMode.Clamp;
                            }
                        }

                        JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(item), texProp);
                        break;
                    }

                    default:
                        Debug.Log(this.name + "[Unknown Property Type] " + item.name + " (" + item.type.ToString() + ")");
                        break;
                    }
                }
            }
        }