コード例 #1
0
        private void DrawTextureField(ShaderImporterInspector.TextureProp prop)
        {
            Texture texture  = prop.texture;
            Texture texture2 = null;

            EditorGUI.BeginChangeCheck();
            Type textureTypeFromDimension = MaterialEditor.GetTextureTypeFromDimension(prop.dimension);

            if (textureTypeFromDimension != null)
            {
                string t = (!string.IsNullOrEmpty(prop.displayName)) ? prop.displayName : ObjectNames.NicifyVariableName(prop.propertyName);
                texture2 = (EditorGUILayout.MiniThumbnailObjectField(GUIContent.Temp(t), texture, textureTypeFromDimension, new GUILayoutOption[0]) as Texture);
            }
            if (EditorGUI.EndChangeCheck())
            {
                prop.texture = texture2;
            }
        }
コード例 #2
0
        protected override void ResetValues()
        {
            base.ResetValues();
            this.m_Properties.Clear();
            ShaderImporter shaderImporter = base.target as ShaderImporter;

            if (!(shaderImporter == null))
            {
                Shader shader = shaderImporter.GetShader();
                if (!(shader == null))
                {
                    int propertyCount = ShaderUtil.GetPropertyCount(shader);
                    for (int i = 0; i < propertyCount; i++)
                    {
                        if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv)
                        {
                            string  propertyName        = ShaderUtil.GetPropertyName(shader, i);
                            string  propertyDescription = ShaderUtil.GetPropertyDescription(shader, i);
                            bool    flag = !ShaderUtil.IsShaderPropertyNonModifiableTexureProperty(shader, i);
                            Texture texture;
                            if (!flag)
                            {
                                texture = shaderImporter.GetNonModifiableTexture(propertyName);
                            }
                            else
                            {
                                texture = shaderImporter.GetDefaultTexture(propertyName);
                            }
                            ShaderImporterInspector.TextureProp item = new ShaderImporterInspector.TextureProp
                            {
                                propertyName = propertyName,
                                texture      = texture,
                                dimension    = ShaderUtil.GetTexDim(shader, i),
                                displayName  = propertyDescription,
                                modifiable   = flag
                            };
                            this.m_Properties.Add(item);
                        }
                    }
                }
            }
        }