update CCK to 3.10, fixing unity 2021 crash :)
This commit is contained in:
parent
48a978fa2a
commit
d11e0fb3a9
492 changed files with 2165204 additions and 437687 deletions
|
@ -1,257 +1,266 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ABI.CCK.Components;
|
||||
using ABI.CCK.Scripts.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using AnimatorController = UnityEditor.Animations.AnimatorController;
|
||||
using AnimatorControllerParameter = UnityEngine.AnimatorControllerParameter;
|
||||
using AnimatorControllerParameterType = UnityEngine.AnimatorControllerParameterType;
|
||||
|
||||
[CustomEditor(typeof(ABI.CCK.Components.AnimatorDriver))]
|
||||
public class CCK_AnimatorDriverEditor : UnityEditor.Editor
|
||||
[CustomEditor(typeof(AnimatorDriver))]
|
||||
public class CCK_AnimatorDriverEditor : Editor
|
||||
{
|
||||
private AnimatorDriver _animatorDriver;
|
||||
|
||||
private ReorderableList _onEnterList;
|
||||
private ReorderableList _onExitList;
|
||||
|
||||
private List<string> animatorParamNames = new List<string>();
|
||||
private List<string> animatorParamNamesDisplay = new List<string>();
|
||||
private List<AnimatorDriverTask.ParameterType> animatorParamTypes = new List<AnimatorDriverTask.ParameterType>();
|
||||
private readonly List<string> _animatorParamNames = new List<string>();
|
||||
private readonly List<AnimatorDriverTask.ParameterType> _animatorParamTypes = new List<AnimatorDriverTask.ParameterType>();
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
private bool _showLocalOnlyHelp;
|
||||
private bool _isInPlayMode;
|
||||
|
||||
#region Unity Events
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_animatorDriver == null) _animatorDriver = (AnimatorDriver) target;
|
||||
if (target == null) return;
|
||||
_animatorDriver = (AnimatorDriver)target;
|
||||
|
||||
animatorParamNames.Clear();
|
||||
animatorParamNamesDisplay.Clear();
|
||||
animatorParamTypes.Clear();
|
||||
|
||||
animatorParamNames.Add("- None -");
|
||||
animatorParamNamesDisplay.Add("- None -");
|
||||
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.None);
|
||||
_isInPlayMode = Application.isPlaying;
|
||||
|
||||
_animatorParamNames.Clear();
|
||||
_animatorParamTypes.Clear();
|
||||
// TODO: add parameter type display in parameter dropdown
|
||||
|
||||
var behaviorContext = AnimatorController.FindStateMachineBehaviourContext(_animatorDriver);
|
||||
if (behaviorContext.Length > 0)
|
||||
{
|
||||
var controller = behaviorContext[0].animatorController;
|
||||
|
||||
foreach (var parameter in controller.parameters)
|
||||
AnimatorController controller = behaviorContext[0].animatorController;
|
||||
foreach (AnimatorControllerParameter parameter in controller.parameters)
|
||||
{
|
||||
switch (parameter.type)
|
||||
{
|
||||
case AnimatorControllerParameterType.Bool:
|
||||
animatorParamNames.Add($"{parameter.name}");
|
||||
animatorParamNamesDisplay.Add($"{parameter.name} (Bool)");
|
||||
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Bool);
|
||||
_animatorParamNames.Add($"{parameter.name}");
|
||||
_animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Bool);
|
||||
break;
|
||||
case AnimatorControllerParameterType.Float:
|
||||
animatorParamNames.Add($"{parameter.name}");
|
||||
animatorParamNamesDisplay.Add($"{parameter.name} (Float)");
|
||||
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Float);
|
||||
_animatorParamNames.Add($"{parameter.name}");
|
||||
_animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Float);
|
||||
break;
|
||||
case AnimatorControllerParameterType.Int:
|
||||
animatorParamNames.Add($"{parameter.name}");
|
||||
animatorParamNamesDisplay.Add($"{parameter.name} (Int)");
|
||||
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Int);
|
||||
_animatorParamNames.Add($"{parameter.name}");
|
||||
_animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Int);
|
||||
break;
|
||||
case AnimatorControllerParameterType.Trigger:
|
||||
animatorParamNames.Add($"{parameter.name}");
|
||||
animatorParamNamesDisplay.Add($"{parameter.name} (Trigger)");
|
||||
animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Trigger);
|
||||
_animatorParamNames.Add($"{parameter.name}");
|
||||
_animatorParamTypes.Add(AnimatorDriverTask.ParameterType.Trigger);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_onEnterList == null)
|
||||
{
|
||||
_onEnterList = new ReorderableList(_animatorDriver.EnterTasks, typeof(AnimatorDriverTask),
|
||||
true, true, true, true);
|
||||
_onEnterList.drawHeaderCallback = OnDrawHeaderTaskEnter;
|
||||
_onEnterList.drawElementCallback = OnDrawElementTaskEnter;
|
||||
_onEnterList.elementHeightCallback = OnHeightElementTaskEnter;
|
||||
true, true, !_isInPlayMode, !_isInPlayMode)
|
||||
{
|
||||
drawHeaderCallback = OnDrawHeaderTaskEnter,
|
||||
drawElementCallback = OnDrawElementTaskEnter,
|
||||
elementHeightCallback = OnHeightElementTaskEnter
|
||||
};
|
||||
}
|
||||
|
||||
_onEnterList.DoLayoutList();
|
||||
|
||||
if (_onExitList == null)
|
||||
{
|
||||
_onExitList = new ReorderableList(_animatorDriver.ExitTasks, typeof(AnimatorDriverTask),
|
||||
true, true, true, true);
|
||||
_onExitList.drawHeaderCallback = OnDrawHeaderTaskExit;
|
||||
_onExitList.drawElementCallback = OnDrawElementTaskExit;
|
||||
_onExitList.elementHeightCallback = OnHeightElementTaskExit;
|
||||
true, true, !_isInPlayMode, !_isInPlayMode)
|
||||
{
|
||||
drawHeaderCallback = OnDrawHeaderTaskExit,
|
||||
drawElementCallback = OnDrawElementTaskExit,
|
||||
elementHeightCallback = OnHeightElementTaskExit
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (_animatorDriver == null)
|
||||
return;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
using (new EditorGUILayout.VerticalScope(new GUIStyle() { padding = new RectOffset(10, 10, 10, 10) }))
|
||||
{
|
||||
DrawLocalOnlyToggle();
|
||||
DrawTaskLists();
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
EditorUtility.SetDirty(_animatorDriver);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GUI Drawing
|
||||
|
||||
private void DrawLocalOnlyToggle()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
_animatorDriver.localOnly = EditorGUILayout.Toggle("Local Only", _animatorDriver.localOnly);
|
||||
if (GUILayout.Button("?", GUILayout.Width(25)))
|
||||
_showLocalOnlyHelp = !_showLocalOnlyHelp;
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
if (_showLocalOnlyHelp)
|
||||
{
|
||||
// TODO: Add to LocalizationProvider
|
||||
EditorGUILayout.HelpBox("When 'Local Only' is enabled, the animator driver is executed locally and not for remote users.", MessageType.Info);
|
||||
EditorGUILayout.Space(5);
|
||||
EditorGUILayout.HelpBox("Avatars: Only the wearer.\nSpawnables: Only the prop's owner.\nWorlds: This option is ignored.", MessageType.Info);
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
private void DrawTaskLists()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
_onEnterList.DoLayoutList();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
_onExitList.DoLayoutList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ReorderableList Drawing
|
||||
|
||||
private void OnDrawHeaderTaskEnter(Rect rect)
|
||||
{
|
||||
Rect _rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
GUI.Label(_rect, "On Enter State");
|
||||
Rect labelRect = new Rect(rect.x, rect.y, rect.width - 35, EditorGUIUtility.singleLineHeight);
|
||||
GUI.Label(labelRect, "On Enter Tasks");
|
||||
EditorGUIExtensions.UtilityMenu(rect, _onEnterList,
|
||||
appendAdditionalMenuItems: (menuBuilder, list) => {
|
||||
AppendComponentMenu(menuBuilder, list, true);
|
||||
});
|
||||
}
|
||||
|
||||
private void OnDrawElementTaskEnter(Rect rect, int index, bool isactive, bool isfocused)
|
||||
{
|
||||
if (index > _animatorDriver.EnterTasks.Count) return;
|
||||
if (index >= _animatorDriver.EnterTasks.Count) return;
|
||||
AnimatorDriverTask element = _animatorDriver.EnterTasks[index];
|
||||
|
||||
RenderTask(rect, element);
|
||||
using (new EditorGUI.DisabledScope(_isInPlayMode))
|
||||
RenderTask(rect, element);
|
||||
}
|
||||
|
||||
private float OnHeightElementTaskEnter(int index)
|
||||
{
|
||||
int length = 3;
|
||||
const int length = 3;
|
||||
if (index >= _animatorDriver.EnterTasks.Count)
|
||||
return 1.25f * length * EditorGUIUtility.singleLineHeight;
|
||||
|
||||
if (index > _animatorDriver.EnterTasks.Count) return 1.25f * length * EditorGUIUtility.singleLineHeight;
|
||||
AnimatorDriverTask task = _animatorDriver.EnterTasks[index];
|
||||
|
||||
return (length + TaskHeight(task)) * 1.25f * EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
|
||||
private void OnDrawHeaderTaskExit(Rect rect)
|
||||
{
|
||||
Rect _rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
GUI.Label(_rect, "On Exit State");
|
||||
Rect labelRect = new Rect(rect.x, rect.y, rect.width - 35, EditorGUIUtility.singleLineHeight);
|
||||
GUI.Label(labelRect, "On Exit Tasks");
|
||||
EditorGUIExtensions.UtilityMenu(rect, _onExitList,
|
||||
appendAdditionalMenuItems: (menuBuilder, list) => {
|
||||
AppendComponentMenu(menuBuilder, list, false);
|
||||
});
|
||||
}
|
||||
|
||||
private void OnDrawElementTaskExit(Rect rect, int index, bool isactive, bool isfocused)
|
||||
{
|
||||
if (index > _animatorDriver.ExitTasks.Count) return;
|
||||
if (index >= _animatorDriver.ExitTasks.Count) return;
|
||||
AnimatorDriverTask element = _animatorDriver.ExitTasks[index];
|
||||
|
||||
RenderTask(rect, element);
|
||||
using (new EditorGUI.DisabledScope(_isInPlayMode))
|
||||
RenderTask(rect, element);
|
||||
}
|
||||
|
||||
private float OnHeightElementTaskExit(int index)
|
||||
{
|
||||
int length = 3;
|
||||
const int length = 3;
|
||||
if (index >= _animatorDriver.ExitTasks.Count)
|
||||
return 1.25f * length * EditorGUIUtility.singleLineHeight;
|
||||
|
||||
if (index > _animatorDriver.ExitTasks.Count) return 1.25f * length * EditorGUIUtility.singleLineHeight;
|
||||
AnimatorDriverTask task = _animatorDriver.ExitTasks[index];
|
||||
|
||||
return (length + TaskHeight(task)) * 1.25f * EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AnimatorDriverTask Drawing
|
||||
|
||||
private int TaskHeight(AnimatorDriverTask task)
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
switch (task.aType)
|
||||
{
|
||||
case AnimatorDriverTask.SourceType.Static:
|
||||
case AnimatorDriverTask.SourceType.Parameter:
|
||||
length += 1;
|
||||
break;
|
||||
case AnimatorDriverTask.SourceType.Random:
|
||||
length += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (task.op != AnimatorDriverTask.Operator.Set)
|
||||
{
|
||||
int length = 2;
|
||||
if (task.aType == AnimatorDriverTask.SourceType.Random)
|
||||
length += 1;
|
||||
|
||||
switch (task.bType)
|
||||
{
|
||||
case AnimatorDriverTask.SourceType.Static:
|
||||
case AnimatorDriverTask.SourceType.Parameter:
|
||||
length += 1;
|
||||
break;
|
||||
case AnimatorDriverTask.SourceType.Random:
|
||||
length += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
length += 1;
|
||||
if (task.op == AnimatorDriverTask.Operator.Set)
|
||||
return length;
|
||||
|
||||
length += task.bType == AnimatorDriverTask.SourceType.Random ? 3 : 2;
|
||||
return length;
|
||||
}
|
||||
|
||||
private void RenderTask(Rect rect, AnimatorDriverTask task)
|
||||
{
|
||||
string formulaDisplay = "";
|
||||
Rect _rect = new Rect(rect.x, rect.y + 2, rect.width, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
Rect _rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
|
||||
float spacing = EditorGUIUtility.singleLineHeight * 1.25f;
|
||||
float originalLabelWidth = EditorGUIUtility.labelWidth;
|
||||
EditorGUIUtility.labelWidth = 100;
|
||||
|
||||
int parameterIndex = Math.Max(animatorParamNames.FindIndex(m => m == task.targetName), 0);
|
||||
EditorGUI.LabelField(_rect, "Parameter");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
int selectedIndex = EditorGUI.Popup(_rect, parameterIndex, animatorParamNamesDisplay.ToArray());
|
||||
task.targetType = animatorParamTypes[selectedIndex];
|
||||
task.targetName = animatorParamNames[selectedIndex];
|
||||
task.targetName = EditorGUIExtensions.AdvancedDropdownInput(_rect, task.targetName, _animatorParamNames,
|
||||
"Parameter", "No Parameters");
|
||||
_rect.y += spacing;
|
||||
|
||||
var formulaDisplay = $"{task.targetName} = ";
|
||||
int parameterIndex = Math.Max(_animatorParamNames.FindIndex(m => m == task.targetName), 0);
|
||||
if (_animatorParamNames.Count != 0 && _animatorParamTypes.Count >= parameterIndex)
|
||||
task.targetType = _animatorParamTypes[parameterIndex];
|
||||
|
||||
task.op = (AnimatorDriverTask.Operator)EditorGUI.EnumPopup(_rect, "Operation", task.op);
|
||||
_rect.y += spacing;
|
||||
|
||||
formulaDisplay = $"{task.targetName} = ";
|
||||
|
||||
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
|
||||
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
EditorGUI.LabelField(_rect, "Operation");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
task.op = (AnimatorDriverTask.Operator) EditorGUI.EnumPopup(_rect, task.op);
|
||||
|
||||
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
|
||||
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
EditorGUI.LabelField(_rect, "A Type");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
task.aType = (AnimatorDriverTask.SourceType) EditorGUI.EnumPopup(_rect, task.aType);
|
||||
|
||||
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
|
||||
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
|
||||
task.aType = (AnimatorDriverTask.SourceType)EditorGUI.EnumPopup(_rect, "A Type", task.aType);
|
||||
_rect.y += spacing;
|
||||
|
||||
switch (task.aType)
|
||||
{
|
||||
case AnimatorDriverTask.SourceType.Static:
|
||||
EditorGUI.LabelField(_rect, "A Value");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
task.aValue = EditorGUI.FloatField(_rect, task.aValue);
|
||||
|
||||
task.aValue = EditorGUI.FloatField(_rect, "A Value", task.aValue);
|
||||
_rect.y += spacing;
|
||||
formulaDisplay += $"{task.aValue} ";
|
||||
break;
|
||||
case AnimatorDriverTask.SourceType.Parameter:
|
||||
parameterIndex = Math.Max(animatorParamNames.FindIndex(m => m == task.aName), 0);
|
||||
EditorGUI.LabelField(_rect, "Parameter A");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
selectedIndex = EditorGUI.Popup(_rect, parameterIndex, animatorParamNamesDisplay.ToArray());
|
||||
task.aParamType = animatorParamTypes[selectedIndex];
|
||||
task.aName = animatorParamNames[selectedIndex];
|
||||
|
||||
task.aName = EditorGUIExtensions.AdvancedDropdownInput(_rect, task.aName, _animatorParamNames,
|
||||
"Parameter A", "No Parameters");
|
||||
_rect.y += spacing;
|
||||
parameterIndex = Math.Max(_animatorParamNames.FindIndex(m => m == task.aName), 0);
|
||||
task.aParamType = _animatorParamTypes[parameterIndex];
|
||||
formulaDisplay += $"{task.aName} ";
|
||||
break;
|
||||
case AnimatorDriverTask.SourceType.Random:
|
||||
EditorGUI.LabelField(_rect, "A Min");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
task.aValue = EditorGUI.FloatField(_rect, task.aValue);
|
||||
|
||||
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
|
||||
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
EditorGUI.LabelField(_rect, "A Max");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
task.aMax = Convert.ToSingle(EditorGUI.TextField(_rect, task.aMax.ToString()));
|
||||
|
||||
task.aValue = EditorGUI.FloatField(_rect, "A Min", task.aValue);
|
||||
_rect.y += spacing;
|
||||
task.aMax = EditorGUI.FloatField(_rect, "A Max", task.aMax);
|
||||
_rect.y += spacing;
|
||||
formulaDisplay += $"Rand({task.aValue}, {task.aMax}) ";
|
||||
break;
|
||||
}
|
||||
|
||||
if (task.op != AnimatorDriverTask.Operator.Set)
|
||||
{
|
||||
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
|
||||
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
switch (task.op)
|
||||
{
|
||||
case AnimatorDriverTask.Operator.Addition:
|
||||
|
@ -295,59 +304,81 @@ public class CCK_AnimatorDriverEditor : UnityEditor.Editor
|
|||
break;
|
||||
}
|
||||
|
||||
EditorGUI.LabelField(_rect, "B Type");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
task.bType = (AnimatorDriverTask.SourceType) EditorGUI.EnumPopup(_rect, task.bType);
|
||||
|
||||
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
|
||||
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
|
||||
task.bType = (AnimatorDriverTask.SourceType) EditorGUI.EnumPopup(_rect, "B Type", task.bType);
|
||||
_rect.y += spacing;
|
||||
|
||||
switch (task.bType)
|
||||
{
|
||||
case AnimatorDriverTask.SourceType.Static:
|
||||
EditorGUI.LabelField(_rect, "B Value");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
task.bValue = EditorGUI.FloatField(_rect, task.bValue);
|
||||
|
||||
task.bValue = EditorGUI.FloatField(_rect, "B Value", task.bValue);
|
||||
_rect.y += spacing;
|
||||
formulaDisplay += $"{task.bValue} ";
|
||||
break;
|
||||
case AnimatorDriverTask.SourceType.Parameter:
|
||||
parameterIndex = Math.Max(animatorParamNames.FindIndex(m => m == task.bName), 0);
|
||||
EditorGUI.LabelField(_rect, "Parameter B");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
selectedIndex = EditorGUI.Popup(_rect, parameterIndex, animatorParamNamesDisplay.ToArray());
|
||||
task.bParamType = animatorParamTypes[selectedIndex];
|
||||
task.bName = animatorParamNames[selectedIndex];
|
||||
|
||||
task.bName = EditorGUIExtensions.AdvancedDropdownInput(_rect, task.bName, _animatorParamNames,
|
||||
"Parameter B", "No Parameters");
|
||||
_rect.y += spacing;
|
||||
parameterIndex = Math.Max(_animatorParamNames.FindIndex(m => m == task.bName), 0);
|
||||
task.bParamType = _animatorParamTypes[parameterIndex];
|
||||
formulaDisplay += $"{task.bName} ";
|
||||
break;
|
||||
case AnimatorDriverTask.SourceType.Random:
|
||||
EditorGUI.LabelField(_rect, "B Min");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
task.bValue = EditorGUI.FloatField(_rect, task.bValue);
|
||||
|
||||
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
|
||||
_rect = new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
EditorGUI.LabelField(_rect, "B Max");
|
||||
_rect.x += 100;
|
||||
_rect.width = rect.width - 100;
|
||||
task.bMax = Convert.ToSingle(EditorGUI.TextField(_rect, task.bMax.ToString()));
|
||||
|
||||
task.bValue = EditorGUI.FloatField(_rect, "B Min", task.bValue);
|
||||
_rect.y += spacing;
|
||||
task.bMax = EditorGUI.FloatField(_rect, "B Max", task.bMax);
|
||||
_rect.y += spacing;
|
||||
formulaDisplay += $"Rand({task.bValue}, {task.bMax}) ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.LabelField(_rect, task.targetName == "" ? "No Parameter" : formulaDisplay,
|
||||
new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold });
|
||||
|
||||
var boldtext = new GUIStyle (GUI.skin.label);
|
||||
boldtext.fontStyle = FontStyle.Bold;
|
||||
|
||||
rect.y += EditorGUIUtility.singleLineHeight * 1.25f;
|
||||
_rect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
|
||||
EditorGUI.LabelField(_rect, task.targetName == "- None -"?"Parameter = A":formulaDisplay, boldtext);
|
||||
EditorGUIUtility.labelWidth = originalLabelWidth;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Utility
|
||||
|
||||
private void AppendComponentMenu(GenericMenuBuilder genericMenuBuilder, ReorderableList list, bool isEnterList)
|
||||
{
|
||||
bool hasSelectedTask = list.index != -1;
|
||||
bool hasTasks = list.count > 0;
|
||||
|
||||
if (isEnterList)
|
||||
{
|
||||
genericMenuBuilder.AddMenuItem("To Exit Task", hasTasks && hasSelectedTask, () => ConvertSelectedTask(list, _animatorDriver.EnterTasks, _animatorDriver.ExitTasks));
|
||||
genericMenuBuilder.AddMenuItem("All to Exit Task", hasTasks, ConvertAllTasksToExit);
|
||||
}
|
||||
else
|
||||
{
|
||||
genericMenuBuilder.AddMenuItem("To Enter Task", hasTasks && hasSelectedTask, () => ConvertSelectedTask(list, _animatorDriver.ExitTasks, _animatorDriver.EnterTasks));
|
||||
genericMenuBuilder.AddMenuItem("All to Enter Task", hasTasks, ConvertAllTasksToEnter);
|
||||
}
|
||||
}
|
||||
|
||||
private void ConvertAllTasksToEnter()
|
||||
{
|
||||
_animatorDriver.EnterTasks.AddRange(_animatorDriver.ExitTasks);
|
||||
_animatorDriver.ExitTasks.Clear();
|
||||
}
|
||||
|
||||
private void ConvertAllTasksToExit()
|
||||
{
|
||||
_animatorDriver.ExitTasks.AddRange(_animatorDriver.EnterTasks);
|
||||
_animatorDriver.EnterTasks.Clear();
|
||||
}
|
||||
|
||||
private void ConvertSelectedTask(ReorderableList list, List<AnimatorDriverTask> fromTasks, List<AnimatorDriverTask> toTasks)
|
||||
{
|
||||
if (list.index == -1 || list.index >= fromTasks.Count) return;
|
||||
|
||||
AnimatorDriverTask selectedTask = fromTasks[list.index];
|
||||
fromTasks.RemoveAt(list.index);
|
||||
toTasks.Add(selectedTask);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue