@@ -21,7 +21,7 @@ namespace Zigurous.Architecture.Editor
2121 [ CustomPropertyDrawer ( typeof ( Vector4Reference ) , true ) ]
2222 public class ValueReferencePropertyDrawer : PropertyDrawer
2323 {
24- private readonly string [ ] popupOptions = { "Use Constant " , "Use Variable" } ;
24+ private readonly string [ ] popupOptions = { "Fixed Value " , "Variable" } ;
2525 private static GUIStyle popupStyle ;
2626
2727 public override void OnGUI ( Rect position , SerializedProperty property , GUIContent label )
@@ -32,29 +32,29 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
3232 popupStyle . imagePosition = ImagePosition . ImageOnly ;
3333 }
3434
35- SerializedProperty useConstant = property . FindPropertyRelative ( "useConstant" ) ;
36- SerializedProperty constantValue = property . FindPropertyRelative ( "constantValue" ) ;
35+ SerializedProperty useVariable = property . FindPropertyRelative ( "useVariable" ) ;
3736 SerializedProperty variable = property . FindPropertyRelative ( "variable" ) ;
37+ SerializedProperty fixedValue = property . FindPropertyRelative ( "fixedValue" ) ;
3838
3939 label = EditorGUI . BeginProperty ( position , label , property ) ;
4040 position = EditorGUI . PrefixLabel ( position , label ) ;
4141
42+ int indent = EditorGUI . indentLevel ;
43+ EditorGUI . indentLevel = 0 ;
44+
4245 Rect popupRect = new Rect ( position ) ;
4346 popupRect . width = popupStyle . fixedWidth + popupStyle . margin . right ;
44- popupRect . height = EditorGUIUtility . singleLineHeight ;
45- popupRect . y += ( popupRect . height - popupStyle . fixedHeight ) / 2f ;
47+ popupRect . height = popupStyle . fixedHeight ;
48+ popupRect . x += position . width - popupRect . width ;
49+ popupRect . y += ( EditorGUIUtility . singleLineHeight - popupStyle . fixedHeight ) / 2f ;
4650 position . width -= popupRect . width ;
47- popupRect . x += position . width ;
4851
4952 EditorGUI . BeginChangeCheck ( ) ;
5053
51- int indent = EditorGUI . indentLevel ;
52- EditorGUI . indentLevel = 0 ;
53-
54- int result = EditorGUI . Popup ( popupRect , useConstant . boolValue ? 0 : 1 , popupOptions , popupStyle ) ;
55- useConstant . boolValue = result == 0 ;
54+ int result = EditorGUI . Popup ( popupRect , useVariable . boolValue ? 1 : 0 , popupOptions , popupStyle ) ;
55+ useVariable . boolValue = result == 1 ;
5656
57- EditorGUI . PropertyField ( position , useConstant . boolValue ? constantValue : variable , GUIContent . none , true ) ;
57+ EditorGUI . PropertyField ( position , useVariable . boolValue ? variable : fixedValue , GUIContent . none , true ) ;
5858
5959 if ( EditorGUI . EndChangeCheck ( ) ) {
6060 property . serializedObject . ApplyModifiedProperties ( ) ;
@@ -66,11 +66,11 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
6666
6767 public override float GetPropertyHeight ( SerializedProperty property , GUIContent label )
6868 {
69- SerializedProperty useConstant = property . FindPropertyRelative ( "useConstant" ) ;
70- SerializedProperty constantValue = property . FindPropertyRelative ( "constantValue" ) ;
69+ SerializedProperty useVariable = property . FindPropertyRelative ( "useVariable" ) ;
7170 SerializedProperty variable = property . FindPropertyRelative ( "variable" ) ;
71+ SerializedProperty fixedValue = property . FindPropertyRelative ( "fixedValue" ) ;
7272
73- return EditorGUI . GetPropertyHeight ( useConstant . boolValue ? constantValue : variable , true ) ;
73+ return EditorGUI . GetPropertyHeight ( useVariable . boolValue ? variable : fixedValue , true ) ;
7474 }
7575
7676 }
0 commit comments