@@ -7,31 +7,8 @@ namespace ScriptableObjectArchitecture.Editor
77{
88 public static class GenericPropertyDrawer
99 {
10- private const string VALUE_LABEL = "Value" ;
11-
12- private static GUIContent ValueGUIContent
13- {
14- get
15- {
16- if ( _valueGUIContent == null )
17- {
18- _valueGUIContent = new GUIContent ( VALUE_LABEL ) ;
19- }
20-
21- return _valueGUIContent ;
22- }
23- }
24-
25- private static GUIContent _valueGUIContent ;
26-
27- /// <summary>
28- /// Draws a property drawer using the <see cref="EditorGUI"/> methods and the area the drawer is drawn
29- /// in is determined by the passed <see cref="Rect"/> <paramref name="rect"/>.
30- /// </summary>
31- public static void DrawPropertyDrawer ( Rect rect , Type type , SerializedProperty property , GUIContent errorLabel , bool drawValueLabel = false )
10+ public static void DrawPropertyDrawer ( Rect rect , GUIContent label , Type type , SerializedProperty property , GUIContent errorLabel )
3211 {
33- GUIContent label = drawValueLabel ? ValueGUIContent : GUIContent . none ;
34-
3512 if ( SOArchitecture_EditorUtility . HasPropertyDrawer ( type ) || typeof ( Object ) . IsAssignableFrom ( type ) || type . IsEnum )
3613 {
3714 //Unity doesn't like it when you have scene objects on assets,
@@ -47,10 +24,9 @@ public static void DrawPropertyDrawer(Rect rect, Type type, SerializedProperty p
4724 }
4825 else if ( type . IsAssignableFrom ( typeof ( Quaternion ) ) )
4926 {
50- property . quaternionValue = EditorGUI . Vector4Field (
51- rect ,
52- label ,
53- property . quaternionValue . ToVector4 ( ) ) . ToQuaternion ( ) ;
27+ Vector4 displayValue = property . quaternionValue . ToVector4 ( ) ;
28+
29+ property . quaternionValue = EditorGUI . Vector4Field ( rect , label , displayValue ) . ToQuaternion ( ) ;
5430 }
5531 else if ( type . IsAssignableFrom ( typeof ( Vector4 ) ) )
5632 {
@@ -66,14 +42,9 @@ public static void DrawPropertyDrawer(Rect rect, Type type, SerializedProperty p
6642 EditorGUI . LabelField ( rect , errorLabel ) ;
6743 }
6844 }
69-
70- /// <summary>
71- /// Draws a property drawer using the <see cref="EditorGUILayout"/> methods.
72- /// </summary>
73- public static void DrawPropertyDrawerLayout ( Type type , SerializedProperty property , GUIContent errorLabel , bool drawValueLabel = false )
45+
46+ public static void DrawPropertyDrawerLayout ( Type type , GUIContent label , SerializedProperty property , GUIContent errorLabel )
7447 {
75- GUIContent label = drawValueLabel ? ValueGUIContent : GUIContent . none ;
76-
7748 if ( SOArchitecture_EditorUtility . HasPropertyDrawer ( type ) || typeof ( Object ) . IsAssignableFrom ( type ) || type . IsEnum )
7849 {
7950 //Unity doesn't like it when you have scene objects on assets,
@@ -89,9 +60,9 @@ public static void DrawPropertyDrawerLayout(Type type, SerializedProperty proper
8960 }
9061 else if ( type . IsAssignableFrom ( typeof ( Quaternion ) ) )
9162 {
92- property . quaternionValue = EditorGUILayout . Vector4Field (
93- label ,
94- property . quaternionValue . ToVector4 ( ) ) . ToQuaternion ( ) ;
63+ Vector4 displayValue = property . quaternionValue . ToVector4 ( ) ;
64+
65+ property . quaternionValue = EditorGUILayout . Vector4Field ( label , displayValue ) . ToQuaternion ( ) ;
9566 }
9667 else if ( type . IsAssignableFrom ( typeof ( Vector4 ) ) )
9768 {
@@ -107,16 +78,5 @@ public static void DrawPropertyDrawerLayout(Type type, SerializedProperty proper
10778 EditorGUILayout . LabelField ( errorLabel ) ;
10879 }
10980 }
110-
111- /// <summary>
112- /// Returns true if the passed <see cref="Type"/> <paramref name="type"/> should be displayed on
113- /// single line regardless of whether <see cref="EditorGUI.GetPropertyHeight(SerializedProperty)"/>
114- /// says otherwise.
115- /// </summary>
116- public static bool IsSingleLineGUIType ( Type type )
117- {
118- return type . IsAssignableFrom ( typeof ( Vector4 ) ) ||
119- type . IsAssignableFrom ( typeof ( Quaternion ) ) ;
120- }
12181 }
12282}
0 commit comments