UnityEditor.MaterialEditor.TexturePropertyMiniThumbnail C# (CSharp) Method

TexturePropertyMiniThumbnail() public method

public TexturePropertyMiniThumbnail ( Rect position, MaterialProperty prop, string label, string tooltip ) : Texture
position UnityEngine.Rect
prop MaterialProperty
label string
tooltip string
return UnityEngine.Texture
        public Texture TexturePropertyMiniThumbnail(Rect position, MaterialProperty prop, string label, string tooltip)
        {
            Rect rect;
            Rect rect2;
            this.BeginAnimatedCheck(prop);
            EditorGUI.GetRectsForMiniThumbnailField(position, out rect, out rect2);
            EditorGUI.HandlePrefixLabel(position, rect2, GUIContent.Temp(label, tooltip), 0, EditorStyles.label);
            this.EndAnimatedCheck();
            Texture texture = this.TexturePropertyBody(rect, prop);
            Rect rect3 = position;
            rect3.y += position.height;
            rect3.height = 27f;
            this.TextureCompatibilityWarning(prop);
            return texture;
        }

Usage Example

示例#1
0
        // Helper to show texture and color properties
        public static Rect TextureColorProps(MaterialEditor materialEditor, GUIContent label, MaterialProperty textureProp, MaterialProperty colorProp, bool hdr = false)
        {
            Rect rect = EditorGUILayout.GetControlRect();

            EditorGUI.showMixedValue = textureProp.hasMixedValue;
            materialEditor.TexturePropertyMiniThumbnail(rect, textureProp, label.text, label.tooltip);
            EditorGUI.showMixedValue = false;

            if (colorProp != null)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = colorProp.hasMixedValue;
                int indentLevel = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                Rect rectAfterLabel = new Rect(rect.x + EditorGUIUtility.labelWidth, rect.y,
                                               EditorGUIUtility.fieldWidth, EditorGUIUtility.singleLineHeight);
                var col = EditorGUI.ColorField(rectAfterLabel, GUIContent.none, colorProp.colorValue, true,
                                               false, hdr);
                EditorGUI.indentLevel = indentLevel;
                if (EditorGUI.EndChangeCheck())
                {
                    materialEditor.RegisterPropertyChangeUndo(colorProp.displayName);
                    colorProp.colorValue = col;
                }
                EditorGUI.showMixedValue = false;
            }

            return(rect);
        }
All Usage Examples Of UnityEditor.MaterialEditor::TexturePropertyMiniThumbnail
MaterialEditor