MiniThumbnailObjectField() static private method

static private MiniThumbnailObjectField ( GUIContent label, Object obj, Type objType, UnityEditor.EditorGUI validator ) : Object
label UnityEngine.GUIContent
obj Object
objType System.Type
validator UnityEditor.EditorGUI
return Object
示例#1
0
        private void ShowDefaultTextures()
        {
            if (this.propertyNames.Count == 0)
            {
                return;
            }
            EditorGUILayout.LabelField("Default Maps", EditorStyles.boldLabel, new GUILayoutOption[0]);
            for (int i = 0; i < this.propertyNames.Count; i++)
            {
                Texture obj   = this.textures[i];
                Texture value = null;
                EditorGUI.BeginChangeCheck();
                Type type;
                switch (this.dimensions[i])
                {
                case ShaderUtil.ShaderPropertyTexDim.TexDim2D:
                    type = typeof(Texture);
                    break;

                case ShaderUtil.ShaderPropertyTexDim.TexDim3D:
                    type = typeof(Texture3D);
                    break;

                case ShaderUtil.ShaderPropertyTexDim.TexDimCUBE:
                    type = typeof(Cubemap);
                    break;

                case ShaderUtil.ShaderPropertyTexDim.TexDimAny:
                    type = typeof(Texture);
                    break;

                default:
                    type = null;
                    break;
                }
                if (type != null)
                {
                    string t = (!string.IsNullOrEmpty(this.displayNames[i])) ? this.displayNames[i] : ObjectNames.NicifyVariableName(this.propertyNames[i]);
                    value = (EditorGUILayout.MiniThumbnailObjectField(GUIContent.Temp(t), obj, type, null, new GUILayoutOption[0]) as Texture);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    this.textures[i] = value;
                }
            }
        }
        private void ShowDefaultTextures()
        {
            if (this.propertyNames.Count == 0)
            {
                return;
            }
            EditorGUILayout.LabelField("Default Maps", EditorStyles.boldLabel, new GUILayoutOption[0]);
            for (int index = 0; index < this.propertyNames.Count; ++index)
            {
                Texture texture1 = this.textures[index];
                Texture texture2 = (Texture)null;
                EditorGUI.BeginChangeCheck();
                System.Type objType;
                switch (this.dimensions[index])
                {
                case ShaderUtil.ShaderPropertyTexDim.TexDim2D:
                    objType = typeof(Texture);
                    break;

                case ShaderUtil.ShaderPropertyTexDim.TexDim3D:
                    objType = typeof(Texture3D);
                    break;

                case ShaderUtil.ShaderPropertyTexDim.TexDimCUBE:
                    objType = typeof(Cubemap);
                    break;

                case ShaderUtil.ShaderPropertyTexDim.TexDimAny:
                    objType = typeof(Texture);
                    break;

                default:
                    objType = (System.Type)null;
                    break;
                }
                if (objType != null)
                {
                    texture2 = EditorGUILayout.MiniThumbnailObjectField(GUIContent.Temp(!string.IsNullOrEmpty(this.displayNames[index]) ? this.displayNames[index] : ObjectNames.NicifyVariableName(this.propertyNames[index])), (UnityEngine.Object)texture1, objType, (EditorGUI.ObjectFieldValidator)null) as Texture;
                }
                if (EditorGUI.EndChangeCheck())
                {
                    this.textures[index] = texture2;
                }
            }
        }
        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;
            }
        }
        private void DrawTextureField(TextureProp prop)
        {
            var     oldTexture = prop.texture;
            Texture newTexture = null;

            EditorGUI.BeginChangeCheck();

            System.Type textureType = MaterialEditor.GetTextureTypeFromDimension(prop.dimension);

            if (textureType != null)
            {
                // Require at least two character in display name to prevent names like "-"
                var text = string.IsNullOrEmpty(prop.displayName) ? ObjectNames.NicifyVariableName(prop.propertyName) : prop.displayName;
                newTexture = EditorGUILayout.MiniThumbnailObjectField(GUIContent.Temp(text), oldTexture, textureType) as Texture;
            }

            if (EditorGUI.EndChangeCheck())
            {
                prop.texture = newTexture;
            }
        }
        private void DrawTextureField(SerializedProperty prop)
        {
            var     oldTexture = prop.FindPropertyRelative("texture").objectReferenceValue;
            Texture newTexture = null;

            EditorGUI.BeginChangeCheck();

            Type textureType = MaterialEditor.GetTextureTypeFromDimension((TextureDimension)prop.FindPropertyRelative("dimension").intValue);

            if (textureType != null)
            {
                // Require at least two character in display name to prevent names like "-"
                var displayName = prop.FindPropertyRelative("displayName").stringValue;
                var text        = string.IsNullOrEmpty(displayName) ? ObjectNames.NicifyVariableName(prop.FindPropertyRelative("propertyName").stringValue) : displayName;
                newTexture = EditorGUILayout.MiniThumbnailObjectField(GUIContent.Temp(text), oldTexture, textureType) as Texture;
            }

            if (EditorGUI.EndChangeCheck())
            {
                prop.FindPropertyRelative("texture").objectReferenceValue = newTexture;
            }
        }
示例#6
0
 private void ShowDefaultTextures()
 {
     if (this.propertyNames.Count != 0)
     {
         EditorGUILayout.LabelField("Default Maps", EditorStyles.boldLabel, new GUILayoutOption[0]);
         for (int i = 0; i < this.propertyNames.Count; i++)
         {
             Texture texture  = this.textures[i];
             Texture texture2 = null;
             EditorGUI.BeginChangeCheck();
             System.Type textureTypeFromDimension = MaterialEditor.GetTextureTypeFromDimension(this.dimensions[i]);
             if (textureTypeFromDimension != null)
             {
                 string t = !string.IsNullOrEmpty(this.displayNames[i]) ? this.displayNames[i] : ObjectNames.NicifyVariableName(this.propertyNames[i]);
                 texture2 = EditorGUILayout.MiniThumbnailObjectField(GUIContent.Temp(t), texture, textureTypeFromDimension, null, new GUILayoutOption[0]) as Texture;
             }
             if (EditorGUI.EndChangeCheck())
             {
                 this.textures[i] = texture2;
             }
         }
     }
 }