浏览代码

Styling

/main
Ciro Continisio 4 年前
当前提交
5eb2bf05
共有 3 个文件被更改,包括 31 次插入12 次删除
  1. 17
      UOP1_Project/Assets/Scripts/StateMachine/Editor/ContentStyle.cs
  2. 19
      UOP1_Project/Assets/Scripts/StateMachine/Editor/TransitionDisplayHelper.cs
  3. 7
      UOP1_Project/Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs

17
UOP1_Project/Assets/Scripts/StateMachine/Editor/ContentStyle.cs


internal static Color ZebraDark { get; private set; }
internal static Color ZebraLight { get; private set; }
internal static RectOffset Padding { get; private set; }
internal static RectOffset LeftPadding { get; private set; }
internal static RectOffset Margin { get; private set; }
internal static GUIStyle BoldCentered { get; private set; }
internal static GUIStyle StateListStyle { get; private set; }

_initialised = true;
DarkGray = new Color(0.7f, 0.7f, 0.7f);
LightGray = new Color(0.8f, 0.8f, 0.8f);
DarkGray = EditorGUIUtility.isProSkin ? new Color(0.283f, 0.283f, 0.283f) : new Color(0.7f, 0.7f, 0.7f);
LightGray = EditorGUIUtility.isProSkin ? new Color(0.33f, 0.33f, 0.33f) : new Color(0.8f, 0.8f, 0.8f);
LeftPadding = new RectOffset(10, 0, 0, 0);
//Prepare a modification of the GUIStyleState to feed into the GUIStyle, for the text colour
GUIStyleState guiStyleStateNormal = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).label.normal;
//bright text for Professional skin, dark text for Personal skin
guiStyleStateNormal.textColor = EditorGUIUtility.isProSkin ? new Color(.85f, .85f, .85f) : new Color(0.337f, 0.337f, 0.337f);
alignment = TextAnchor.MiddleCenter,
alignment = TextAnchor.MiddleLeft,
padding = LeftPadding,
margin = Margin
margin = Margin,
normal = guiStyleStateNormal,
};
}
}

19
UOP1_Project/Assets/Scripts/StateMachine/Editor/TransitionDisplayHelper.cs


internal bool Display()
{
// Transition Header
EditorGUI.DrawRect(EditorGUILayout.BeginHorizontal(), ContentStyle.DarkGray);
EditorGUI.DrawRect(EditorGUILayout.BeginHorizontal(GUILayout.Height(24)), ContentStyle.DarkGray);
EditorGUILayout.Space(3f, false);
// TODO: Fix the space in between the labels above and the buttons below
// Right now the buttons disappear to the right if the Inspector is made too narrow
if (GUILayout.Button(EditorGUIUtility.IconContent("scrollup"), GUILayout.Width(35), GUILayout.Height(16)))
if (GUILayout.Button(EditorGUIUtility.IconContent("scrollup"), GUILayout.Width(30), GUILayout.Height(18)))
if (GUILayout.Button(EditorGUIUtility.IconContent("scrolldown"), GUILayout.Width(35), GUILayout.Height(16)))
if (GUILayout.Button(EditorGUIUtility.IconContent("scrolldown"), GUILayout.Width(30), GUILayout.Height(18)))
if (GUILayout.Button(EditorGUIUtility.IconContent("Toolbar Minus"), GUILayout.Width(35), GUILayout.Height(16)))
if (GUILayout.Button(EditorGUIUtility.IconContent("Toolbar Minus"), GUILayout.Width(30), GUILayout.Height(18)))
{
_editor.RemoveTransition(SerializedTransition.Index);
return true;

{
EditorGUI.PropertyField(new Rect(rect.x, rect.y, 150, rect.height), condition, GUIContent.none);
}
EditorGUI.LabelField(new Rect(rect.x + rect.width - 120, rect.y, 20, rect.height), "Is");
EditorGUI.LabelField(new Rect(rect.x + rect.width - 80, rect.y, 20, rect.height), "Is");
EditorGUI.PropertyField(new Rect(rect.x + 20, rect.y + EditorGUIUtility.singleLineHeight + 5, 60, rect.height), prop.FindPropertyRelative("Operator"), GUIContent.none);
// Only display the logic condition if there's another one after this
if(index < reorderableList.count - 1)
EditorGUI.PropertyField(new Rect(rect.x + 20, rect.y + EditorGUIUtility.singleLineHeight + 5, 60, rect.height), prop.FindPropertyRelative("Operator"), GUIContent.none);
};
reorderableList.onChangedCallback += list => list.serializedProperty.serializedObject.ApplyModifiedProperties();

7
UOP1_Project/Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs


private void TransitionTableGUI()
{
Separator();
EditorGUILayout.HelpBox("Click on any State's name to see the Transitions it contains, or click the Pencil/Wrench icon to see its Actions.", MessageType.Info);
Separator();
serializedObject.UpdateIfRequiredOrScript();
// For each fromState

EndFoldoutHeaderGroup();
EndVertical();
GUILayout.HorizontalSlider(0, 0, 0);
Separator();
//GUILayout.HorizontalSlider(0, 0, 0);
Separator();
}

正在加载...
取消
保存