protected override void OnHeaderGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.inspectorBig);
            Texture2D icon = AssetPreview.GetMiniTypeThumbnail(typeof(Grid));

            GUILayout.Label(icon, GUILayout.Width(iconSize), GUILayout.Height(iconSize));
            EditorGUILayout.BeginVertical();
            GUILayout.Label(Styles.gridSelectionLabel);
            GridSelection.position = EditorGUILayout.BoundsIntField(GUIContent.none, GridSelection.position);
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
            DrawHeaderHelpAndSettingsGUI(GUILayoutUtility.GetLastRect());
        }
示例#2
0
        protected override void OnHeaderGUI()
        {
            EditorGUILayout.BeginHorizontal(GridSelectionEditor.Styles.header, new GUILayoutOption[0]);
            Texture2D miniTypeThumbnail = AssetPreview.GetMiniTypeThumbnail(typeof(Grid));

            GUILayout.Label(miniTypeThumbnail, new GUILayoutOption[]
            {
                GUILayout.Width(32f),
                GUILayout.Height(32f)
            });
            EditorGUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(GridSelectionEditor.Styles.gridSelectionLabel, new GUILayoutOption[0]);
            GridSelection.position = EditorGUILayout.BoundsIntField(GUIContent.none, GridSelection.position, new GUILayoutOption[0]);
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
            this.DrawHeaderHelpAndSettingsGUI(GUILayoutUtility.GetLastRect());
        }
        public static void DefaultLayoutField(this SerializedProperty p, GUIContent label = null, bool includeChildren = false, GUIStyle style = null, params GUILayoutOption[] options)
        {
            if (label == null)
            {
                label = new GUIContent(p.name, p.tooltip);
            }
            bool s = style != null;

            switch (p.propertyType)
            {
            case SerializedPropertyType.Integer:
                if (s)
                {
                    EditorGUILayout.IntField(label, p.intValue, style, options);
                }
                else
                {
                    EditorGUILayout.IntField(label, p.intValue, options);
                }
                break;

            case SerializedPropertyType.Boolean:
                if (s)
                {
                    EditorGUILayout.Toggle(label, p.boolValue, style, options);
                }
                else
                {
                    EditorGUILayout.Toggle(label, p.boolValue, options);
                }
                break;

            case SerializedPropertyType.Float:
                if (s)
                {
                    EditorGUILayout.FloatField(label, p.floatValue, style, options);
                }
                else
                {
                    EditorGUILayout.FloatField(label, p.floatValue, options);
                }
                break;

            case SerializedPropertyType.String:
                if (s)
                {
                    EditorGUILayout.TextField(label, p.stringValue, style, options);
                }
                else
                {
                    EditorGUILayout.TextField(label, p.stringValue, options);
                }
                break;

            case SerializedPropertyType.Color:
                EditorGUILayout.ColorField(label, p.colorValue, options);
                break;

            case SerializedPropertyType.ObjectReference:
                EditorGUILayout.ObjectField(p, label, options);
                break;

            case SerializedPropertyType.LayerMask:
                if (s)
                {
                    EditorGUILayout.LayerField(label, p.intValue, style, options);
                }
                else
                {
                    EditorGUILayout.LayerField(label, p.intValue, options);
                }
                break;

            case SerializedPropertyType.Enum:
                if (s)
                {
                    EditorGUILayout.IntField(label, p.intValue, style, options);
                }
                else
                {
                    EditorGUILayout.IntField(label, p.intValue, options);
                }
                break;

            case SerializedPropertyType.Vector2:
                EditorGUILayout.Vector2Field(label, p.vector2Value, options);
                break;

            case SerializedPropertyType.Vector3:
                EditorGUILayout.Vector3Field(label, p.vector3Value, options);
                break;

            case SerializedPropertyType.Vector4:
                EditorGUILayout.Vector4Field(label, p.vector4Value, options);
                break;

            case SerializedPropertyType.Rect:
                EditorGUILayout.RectField(label, p.rectValue, options);
                break;

            case SerializedPropertyType.ArraySize:
                if (s)
                {
                    EditorGUILayout.IntField(label, p.intValue, style, options);
                }
                else
                {
                    EditorGUILayout.IntField(label, p.intValue, options);
                }
                break;

            case SerializedPropertyType.Character:
                if (s)
                {
                    EditorGUILayout.IntField(label, p.intValue, style, options);
                }
                else
                {
                    EditorGUILayout.IntField(label, p.intValue, options);
                }
                break;

            case SerializedPropertyType.AnimationCurve:
                if (s)
                {
                    EditorGUILayout.LabelField(label, style, options);
                }
                else
                {
                    EditorGUILayout.LabelField(label, options);
                }
                break;

            case SerializedPropertyType.Bounds:
                EditorGUILayout.BoundsField(label, p.boundsValue, options);
                break;

            case SerializedPropertyType.Gradient:
                if (s)
                {
                    EditorGUILayout.LabelField(label, style, options);
                }
                else
                {
                    EditorGUILayout.LabelField(label, options);
                }
                break;

            case SerializedPropertyType.Quaternion:
                EditorGUILayout.Vector4Field(label, p.vector4Value, options);
                break;

            case SerializedPropertyType.ExposedReference:
                EditorGUILayout.ObjectField(p, label, options);
                break;

            case SerializedPropertyType.FixedBufferSize:
                if (s)
                {
                    EditorGUILayout.IntField(label, p.intValue, style, options);
                }
                else
                {
                    EditorGUILayout.IntField(label, p.intValue, options);
                }
                break;

            case SerializedPropertyType.Vector2Int:
                EditorGUILayout.Vector2IntField(label, p.vector2IntValue, options);
                break;

            case SerializedPropertyType.Vector3Int:
                EditorGUILayout.Vector3IntField(label, p.vector3IntValue, options);
                break;

            case SerializedPropertyType.RectInt:
                EditorGUILayout.RectIntField(label, p.rectIntValue, options);
                break;

            case SerializedPropertyType.BoundsInt:
                EditorGUILayout.BoundsIntField(label, p.boundsIntValue, options);
                break;

            case SerializedPropertyType.Generic:
                if (s)
                {
                    EditorGUILayout.LabelField(label, new GUIContent(p.type), style, options);
                }
                else
                {
                    EditorGUILayout.LabelField(label, new GUIContent(p.type), options);
                }
                break;

            default:
                EditorGUILayout.PropertyField(p, label, includeChildren, options);
                break;
            }
        }