Skip to content

Commit 604c122

Browse files
committed
Move the Custom tab's add buttons into the content
The empty state shows the two kinds of custom animation as cards, and the add buttons sit under the last animation; the action bar goes to Generate. The avatar bar's buttons size to their text so Use Selection isn't clipped.
1 parent 9d3cf03 commit 604c122

2 files changed

Lines changed: 62 additions & 11 deletions

File tree

‎Packages/net.pawlygon.unitytools/Editor/FaceTrackingExtras.Custom.cs‎

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,31 +72,82 @@ private void DrawCustomTab()
7272

7373
if (profile.customAnimations.Count == 0)
7474
{
75-
EditorGUILayout.LabelField("No custom animations yet. Add one below.", PawlygonEditorUI.SubLabelStyle);
75+
EditorGUILayout.Space(8f);
76+
DrawAddChoices();
7677
}
7778
}
7879

80+
if (profile.customAnimations.Count == 0) return;
81+
7982
for (int i = 0; i < profile.customAnimations.Count; i++)
8083
{
8184
EditorGUILayout.Space(6f);
8285
DrawCustomAnimationCard(i, catalog);
8386
}
87+
88+
EditorGUILayout.Space(6f);
89+
using (new EditorGUILayout.HorizontalScope())
90+
{
91+
if (GUILayout.Button(new GUIContent("+ Follow a Parameter", FollowChoiceHint), GUILayout.Height(24f)))
92+
{
93+
AddCustomAnimation(FTExtrasCustomMode.Follow);
94+
GUIUtility.ExitGUI();
95+
}
96+
if (GUILayout.Button(new GUIContent("+ Play When…", TriggerChoiceHint), GUILayout.Height(24f)))
97+
{
98+
AddCustomAnimation(FTExtrasCustomMode.Trigger);
99+
GUIUtility.ExitGUI();
100+
}
101+
}
84102
}
85103

86-
private void DrawCustomActions()
104+
private const string FollowChoiceHint = "The parameter's value drives the animation, e.g. a blush that fades in with cheek puff.";
105+
private const string TriggerChoiceHint = "Plays when conditions are met, e.g. an eye shine when both brows stay up for a second.";
106+
107+
private GUIStyle choiceCardStyle;
108+
109+
/// <summary>
110+
/// Empty state: the two kinds of custom animation as large cards, so the first step is in the content
111+
/// rather than at the bottom of a tall window.
112+
/// </summary>
113+
private void DrawAddChoices()
87114
{
88-
PawlygonEditorUI.BeginActionBar();
89-
if (PawlygonEditorUI.DrawSecondaryButton("+ Follow a Parameter"))
115+
if (choiceCardStyle == null)
90116
{
91-
AddCustomAnimation(FTExtrasCustomMode.Follow);
92-
GUIUtility.ExitGUI();
117+
choiceCardStyle = new GUIStyle(GUI.skin.button)
118+
{
119+
richText = true,
120+
wordWrap = true,
121+
alignment = TextAnchor.UpperLeft,
122+
padding = new RectOffset(10, 10, 8, 8),
123+
};
93124
}
94-
if (PawlygonEditorUI.DrawSecondaryButton("+ Play When…"))
125+
126+
using (new EditorGUILayout.HorizontalScope())
95127
{
96-
AddCustomAnimation(FTExtrasCustomMode.Trigger);
97-
GUIUtility.ExitGUI();
128+
if (GUILayout.Button($"<b>+ Follow a Parameter</b>\n<size=11>{FollowChoiceHint}</size>", choiceCardStyle, GUILayout.MinHeight(58f), GUILayout.ExpandWidth(true)))
129+
{
130+
AddCustomAnimation(FTExtrasCustomMode.Follow);
131+
GUIUtility.ExitGUI();
132+
}
133+
GUILayout.Space(6f);
134+
if (GUILayout.Button($"<b>+ Play When…</b>\n<size=11>{TriggerChoiceHint}</size>", choiceCardStyle, GUILayout.MinHeight(58f), GUILayout.ExpandWidth(true)))
135+
{
136+
AddCustomAnimation(FTExtrasCustomMode.Trigger);
137+
GUIUtility.ExitGUI();
138+
}
98139
}
140+
}
141+
142+
private void DrawCustomActions()
143+
{
144+
PawlygonEditorUI.BeginActionBar();
99145
GUILayout.FlexibleSpace();
146+
if (PawlygonEditorUI.DrawPrimaryButton("Next: Generate", 28f, GUILayout.Width(170f)))
147+
{
148+
SwitchTab(Tab.Generate);
149+
GUIUtility.ExitGUI();
150+
}
100151
PawlygonEditorUI.EndActionBar();
101152
}
102153

‎Packages/net.pawlygon.unitytools/Editor/PawlygonEditorUI.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ public static bool DrawAvatarBar(EditorWindow owner, ref GameObject avatar, stri
614614
using (new EditorGUI.DisabledScope(sceneAvatars.Count == 0 || owner == null))
615615
{
616616
var dropdown = new GUIContent("Scene ▾", sceneAvatars.Count == 0 ? "No avatars in the open scenes." : "Pick one of the avatars in the open scenes.");
617-
if (GUILayout.Button(dropdown, EditorStyles.miniButton, GUILayout.Width(58f)))
617+
if (GUILayout.Button(dropdown, EditorStyles.miniButton, GUILayout.Width(EditorStyles.miniButton.CalcSize(dropdown).x + 4f)))
618618
{
619619
ShowSceneAvatarMenu(owner, sceneAvatars, avatar);
620620
}
@@ -626,7 +626,7 @@ public static bool DrawAvatarBar(EditorWindow owner, ref GameObject avatar, stri
626626
var useSelection = new GUIContent("Use Selection", fromSelection != null
627627
? $"Use '{fromSelection.name}', the avatar containing the selected object."
628628
: "Select an avatar (or any object inside it) in the Hierarchy.");
629-
if (GUILayout.Button(useSelection, EditorStyles.miniButton, GUILayout.Width(88f)))
629+
if (GUILayout.Button(useSelection, EditorStyles.miniButton, GUILayout.Width(EditorStyles.miniButton.CalcSize(useSelection).x + 4f)))
630630
{
631631
avatar = fromSelection;
632632
changed = true;

0 commit comments

Comments
 (0)