15 SerializedProperty textComponent;
16 SerializedProperty expandWidth, expandHeight;
17 SerializedProperty paddingWidth, paddingHeight;
18 SerializedProperty flexibleWidth, flexibleHeight;
22 textComponent = serializedObject.FindProperty(
"text");
23 expandWidth = serializedObject.FindProperty(
"expandWidth");
24 expandHeight = serializedObject.FindProperty(
"expandHeight");
25 paddingWidth = serializedObject.FindProperty(
"paddingWidth");
26 paddingHeight = serializedObject.FindProperty(
"paddingHeight");
27 flexibleWidth = serializedObject.FindProperty(
"m_FlexibleWidth");
28 flexibleHeight = serializedObject.FindProperty(
"m_FlexibleHeight");
33 serializedObject.Update();
35 EditorGUILayout.PropertyField(textComponent);
37 GUILayout.BeginHorizontal();
38 expandWidth.boolValue = EditorGUILayout.Toggle(
"Expand Width", expandWidth.boolValue);
39 GUI.enabled = expandWidth.boolValue;
40 EditorGUIUtility.labelWidth = 60f;
41 paddingWidth.floatValue = EditorGUILayout.FloatField(
"Padding", paddingWidth.floatValue);
42 EditorGUIUtility.labelWidth = 0f;
43 GUILayout.EndHorizontal();
45 GUILayout.BeginHorizontal();
47 expandHeight.boolValue = EditorGUILayout.Toggle(
"Expand Height", expandHeight.boolValue);
48 GUI.enabled = expandHeight.boolValue;
49 EditorGUIUtility.labelWidth = 60f;
50 paddingHeight.floatValue = EditorGUILayout.FloatField(
"Padding", paddingHeight.floatValue);
51 GUILayout.EndHorizontal();
53 bool flexWidth = flexibleWidth.floatValue > 0;
54 bool flexHeight = flexibleHeight.floatValue > 0;
56 GUILayout.BeginHorizontal();
57 EditorGUIUtility.labelWidth = 0f;
59 flexWidth = EditorGUILayout.Toggle(
"Flexible Width", flexWidth);
61 if(flexWidth && flexibleWidth.floatValue < 0f)
62 flexibleWidth.floatValue = 1f;
63 else if(!flexWidth && flexibleWidth.floatValue > 0f)
64 flexibleWidth.floatValue = -1f;
65 GUI.enabled = flexWidth;
66 EditorGUIUtility.labelWidth = 60f;
67 flexibleWidth.floatValue = EditorGUILayout.FloatField(
"Weight", flexibleWidth.floatValue);
68 GUILayout.EndHorizontal();
70 GUILayout.BeginHorizontal();
72 EditorGUIUtility.labelWidth = 0f;
73 flexHeight = EditorGUILayout.Toggle(
"Flexible Height", flexHeight);
75 if(flexHeight && flexibleHeight.floatValue < 0f)
76 flexibleHeight.floatValue = 1f;
77 else if(!flexHeight && flexibleHeight.floatValue > 0f)
78 flexibleHeight.floatValue = -1f;
79 GUI.enabled = flexHeight;
80 EditorGUIUtility.labelWidth = 60f;
81 flexibleHeight.floatValue = EditorGUILayout.FloatField(
"Weight", flexibleHeight.floatValue);
82 GUILayout.EndHorizontal();
86 serializedObject.ApplyModifiedProperties();
override void OnInspectorGUI()