chore: initial commit
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
// FlexiMotion // https://kybernetik.com.au/flexi-motion // Copyright 2023 Kybernetik //
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static Animancer.Editor.AnimancerGUI;
|
||||
|
||||
namespace Animancer.Editor
|
||||
// namespace FlexiMotion.Editor
|
||||
{
|
||||
/// <summary>[Editor-Only] A <see cref="PropertyDrawer"/> which adds an "Edit" button to a field.</summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Editor/EditableFieldDrawer
|
||||
/// https://kybernetik.com.au/flexi-motion/api/FlexiMotion.Editor/EditableFieldDrawer
|
||||
public abstract class EditableFieldDrawer : PropertyDrawer
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>The method to call when the "Edit" button is clicked.</summary>
|
||||
/// <remarks>Set this in a custom editor before drawing the attributed field then clear it afterwards.</remarks>
|
||||
public static event Action<SerializedProperty> OnEdit;
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
=> EditorGUI.GetPropertyHeight(property, label);
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void OnGUI(Rect area, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
DrawEditableArea(area, property);
|
||||
EditorGUI.PropertyField(area, property, label, true);
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static GUIStyle
|
||||
_LeftAlignedButtonStyle;
|
||||
|
||||
private static readonly GUIContent
|
||||
EditContent = new();
|
||||
|
||||
private void DrawEditableArea(Rect area, SerializedProperty property)
|
||||
{
|
||||
if (property.hasMultipleDifferentValues)
|
||||
return;
|
||||
|
||||
var label = EditContent;
|
||||
label.text = null;
|
||||
label.tooltip = null;
|
||||
|
||||
GetEditButtonLabel(property, label);
|
||||
if (!string.IsNullOrEmpty(label.text))
|
||||
{
|
||||
area.xMin += EditorGUIUtility.labelWidth + StandardSpacing;
|
||||
area.height = LineHeight;
|
||||
|
||||
if (OnEdit != null)
|
||||
{
|
||||
_LeftAlignedButtonStyle ??= new GUIStyle(EditorStyles.miniButton)
|
||||
{
|
||||
alignment = TextAnchor.MiddleLeft,
|
||||
padding = EditorStyles.miniPullDown.padding,
|
||||
};
|
||||
|
||||
if (GUI.Button(area, label, _LeftAlignedButtonStyle))
|
||||
OnEdit(property);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.Label(area, label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Sets the `label` for the "Edit" button.</summary>
|
||||
public abstract void GetEditButtonLabel(SerializedProperty property, GUIContent label);
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1963a995221dc74ab5f720c1bfa566f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,265 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
// FlexiMotion // https://kybernetik.com.au/flexi-motion // Copyright 2023 Kybernetik //
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
#pragma warning disable CS0618 // Type or member is obsolete - Tree View stuff was made generic in Unity 6.2.
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animancer.Editor
|
||||
//namespace FlexiMotion.Editor
|
||||
{
|
||||
/// <summary>An object that provides data to a <see cref="TransformTreeView"/>.</summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Editor/ITransformTreeViewSource
|
||||
/// https://kybernetik.com.au/flexi-motion/api/FlexiMotion.Editor/ITransformTreeViewSource
|
||||
public interface ITransformTreeViewSource
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>The object at the top of the target hierarchy.</summary>
|
||||
Transform Root { get; }
|
||||
|
||||
/// <summary>The objects to show in the view.</summary>
|
||||
IList<Transform> Transforms { get; }
|
||||
|
||||
/// <summary>Adds the items to be displayed in the view.</summary>
|
||||
void AddItems(ref int id, TreeViewItem root);
|
||||
|
||||
/// <summary>Adds an item for the `transform` to be displayed in the view.</summary>
|
||||
TreeViewItem AddItem(ref int id, TreeViewItem parent, Transform transform);
|
||||
|
||||
/// <summary>Called before a row is drawn.</summary>
|
||||
void BeforeRowGUI(Rect area, TreeViewItem item);
|
||||
|
||||
/// <summary>Draws a cell in the <see cref="TreeView"/>.</summary>
|
||||
void DrawCellGUI(Rect area, int column, int row, TreeViewItem item, ref bool isSelectionClick);
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
|
||||
/// <summary>A <see cref="TreeView"/> for displaying <see cref="Transform"/>s alongside other data.</summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Editor/TransformTreeView
|
||||
/// https://kybernetik.com.au/flexi-motion/api/FlexiMotion.Editor/TransformTreeView
|
||||
public class TransformTreeView : TreeView, IDisposable
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>The ID of the root item.</summary>
|
||||
public const int RootID = 0;
|
||||
|
||||
/// <summary>The object which defines what to show in this view.</summary>
|
||||
public readonly ITransformTreeViewSource Source;
|
||||
|
||||
/// <summary>The field used to filter this view.</summary>
|
||||
public readonly SearchField Search = new();
|
||||
|
||||
/// <summary>The <see cref="Transform"/> of each row in this view.</summary>
|
||||
public readonly List<Transform> Transforms = new();
|
||||
|
||||
/************************************************************************************************************************/
|
||||
#region Initialization
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="TransformTreeView"/>.</summary>
|
||||
public TransformTreeView(
|
||||
TreeViewState state,
|
||||
MultiColumnHeader header,
|
||||
ITransformTreeViewSource source)
|
||||
: base(state, header)
|
||||
{
|
||||
Source = source;
|
||||
|
||||
Selection.selectionChanged += OnObjectSelectionChanged;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Cleans up this view.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Selection.selectionChanged -= OnObjectSelectionChanged;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override TreeViewItem BuildRoot()
|
||||
{
|
||||
Transforms.Clear();
|
||||
|
||||
var id = RootID;
|
||||
var root = CreateItem(ref id, -1, "");
|
||||
Transforms.Add(null);
|
||||
|
||||
Source.AddItems(ref id, root);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Adds a new item for the `transform` as a child of the `parent` and increments the `id`.</summary>
|
||||
public virtual TreeViewItem AddItem(ref int id, TreeViewItem parent, Transform transform)
|
||||
{
|
||||
Transforms.Add(transform);
|
||||
|
||||
var item = CreateItem(ref id, parent.depth + 1, transform.name);
|
||||
parent.AddChild(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
/// <summary>Adds a new item for each child of the `transform` recursively.</summary>
|
||||
public void AddItemRecursive(ref int id, TreeViewItem parent, Transform transform)
|
||||
{
|
||||
parent = Source.AddItem(ref id, parent, transform);
|
||||
|
||||
foreach (Transform child in transform)
|
||||
AddItemRecursive(ref id, parent, child);
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Creates a new <see cref="TreeViewItem"/> and increments the `id`.</summary>
|
||||
public static TreeViewItem CreateItem(ref int id, int depth, string displayName)
|
||||
=> new()
|
||||
{
|
||||
id = id++,
|
||||
depth = depth,
|
||||
displayName = displayName,
|
||||
};
|
||||
|
||||
/************************************************************************************************************************/
|
||||
#endregion
|
||||
/************************************************************************************************************************/
|
||||
#region GUI
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Draws the <see cref="SearchField"/> for filtering this view.</summary>
|
||||
public void DrawSearchField(Rect area)
|
||||
{
|
||||
searchString = Search.OnGUI(area, searchString);
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void RowGUI(RowGUIArgs args)
|
||||
{
|
||||
Source.BeforeRowGUI(args.rowRect, args.item);
|
||||
|
||||
var currentEvent = Event.current;
|
||||
var isClick =
|
||||
currentEvent.type == EventType.MouseDown &&
|
||||
args.rowRect.Contains(currentEvent.mousePosition);
|
||||
|
||||
var visibleColumnCount = args.GetNumVisibleColumns();
|
||||
for (int i = 0; i < visibleColumnCount; ++i)
|
||||
{
|
||||
var area = args.GetCellRect(i);
|
||||
if (i == 0)
|
||||
area.xMin += (args.item.depth + 1) * depthIndentWidth;
|
||||
|
||||
Source.DrawCellGUI(area, args.GetColumn(i), args.row, args.item, ref isClick);
|
||||
}
|
||||
|
||||
if (isClick && currentEvent.type == EventType.Used)
|
||||
SelectionClick(args.item, false);
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static readonly List<GameObject>
|
||||
SelectedObjects = new();
|
||||
|
||||
/// <summary>Called whenever the selected rows change.</summary>
|
||||
public event Action<IList<int>> OnSelectionChanged;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void SelectionChanged(IList<int> selectedIds)
|
||||
{
|
||||
base.SelectionChanged(selectedIds);
|
||||
|
||||
SelectedObjects.Clear();
|
||||
|
||||
for (int i = 0; i < selectedIds.Count; i++)
|
||||
if (Transforms.TryGetObject(selectedIds[i], out var transform))
|
||||
SelectedObjects.Add(transform.gameObject);
|
||||
|
||||
Selection.objects = SelectedObjects.ToArray();
|
||||
|
||||
OnSelectionChanged?.Invoke(selectedIds);
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static readonly List<int>
|
||||
SelectedIDs = new();
|
||||
|
||||
/// <summary>Called whenever the <see cref="Selection.objects"/> change.</summary>
|
||||
public void OnObjectSelectionChanged()
|
||||
{
|
||||
var selectedObjects = Selection.objects;
|
||||
|
||||
SelectedIDs.Clear();
|
||||
SelectedIDs.AddRange(GetSelection());
|
||||
|
||||
// Remove IDs that aren't in the Selection.
|
||||
for (int i = SelectedIDs.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (!Transforms.TryGetObject(SelectedIDs[i], out var transform) ||
|
||||
Array.IndexOf(selectedObjects, transform.gameObject) < 0)
|
||||
{
|
||||
SelectedIDs.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
// If no selected rows correspond to a selected object, add all rows of that object.
|
||||
foreach (var selected in selectedObjects)
|
||||
{
|
||||
if (!AnimancerUtilities.TryGetTransform(selected, out var selectedTransform) ||
|
||||
IsAlreadySelected(selectedTransform))
|
||||
continue;
|
||||
|
||||
var index = Transforms.IndexOf(selectedTransform);
|
||||
if (index >= 0)
|
||||
{
|
||||
SelectedIDs.Add(index);
|
||||
|
||||
while (Transforms.TryGetObject(++index, out var transform) &&
|
||||
transform == selectedTransform)
|
||||
SelectedIDs.Add(index);
|
||||
}
|
||||
}
|
||||
|
||||
SetSelection(SelectedIDs);
|
||||
}
|
||||
|
||||
private bool IsAlreadySelected(Transform transform)
|
||||
{
|
||||
for (int i = 0; i < SelectedIDs.Count; i++)
|
||||
{
|
||||
if (!Transforms.TryGetObject(SelectedIDs[i], out var selectedTransform))
|
||||
continue;
|
||||
|
||||
if (selectedTransform == transform)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
#endregion
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3685453dea21e0a4287c1a3d5820d4cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,428 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
// FlexiMotion // https://kybernetik.com.au/flexi-motion // Copyright 2023 Kybernetik //
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
#pragma warning disable CS0618 // Type or member is obsolete - Tree View stuff was made generic in Unity 6.2.
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
using static Animancer.Editor.AnimancerGUI;
|
||||
|
||||
namespace Animancer.Editor
|
||||
{
|
||||
/// <summary>[Editor-Only]
|
||||
/// A <see cref="SerializedComponentDataEditorWindow{TObject, TData}"/>
|
||||
/// which displays a <see cref="TransformTreeView"/>.
|
||||
/// </summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Editor/TransformTreeWindow_2
|
||||
/// https://kybernetik.com.au/flexi-motion/api/FlexiMotion.Editor/TransformTreeWindow_2
|
||||
public abstract class TransformTreeWindow<TObject, TData> :
|
||||
SerializedComponentDataEditorWindow<TObject, TData>,
|
||||
ITransformTreeViewSource
|
||||
where TObject : Component
|
||||
where TData : class, ICopyable<TData>, IEquatable<TData>, new()
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
[SerializeField] private MultiColumnHeaderState _HeaderState;
|
||||
[SerializeField] private TreeViewState _GUIState;
|
||||
|
||||
[NonSerialized] private TransformTreeView _TreeView;
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>The header of the tree view.</summary>
|
||||
public MultiColumnHeaderState HeaderState => _HeaderState;
|
||||
|
||||
/// <summary>The view used to display the <see cref="SerializedDataEditorWindow{TObject, TData}.Data"/>.</summary>
|
||||
public TransformTreeView TreeView => _TreeView;
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
minSize = new Vector2(400, 200);
|
||||
|
||||
Initialize();
|
||||
|
||||
Undo.undoRedoPerformed += ReloadTreeView;
|
||||
Selection.selectionChanged += Repaint;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
|
||||
Undo.undoRedoPerformed -= ReloadTreeView;
|
||||
Selection.selectionChanged -= Repaint;
|
||||
|
||||
_TreeView?.Dispose();
|
||||
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void CaptureData()
|
||||
{
|
||||
base.CaptureData();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes this window if the <see cref="SerializedDataEditorWindow{TObject, TData}.SourceObject"/>
|
||||
/// has been set.
|
||||
/// </summary>
|
||||
protected virtual void Initialize()
|
||||
{
|
||||
if (SourceObject == null)
|
||||
return;
|
||||
|
||||
titleContent = new($"{SourceObject.name}: {SourceObject.GetType().Name}");
|
||||
|
||||
var isNew = _GUIState == null;
|
||||
if (isNew)
|
||||
_GUIState = new();
|
||||
|
||||
if (_TreeView == null)
|
||||
{
|
||||
_TreeView = new(_GUIState, null, this);
|
||||
_TreeView.Reload();
|
||||
_TreeView.OnObjectSelectionChanged();
|
||||
}
|
||||
|
||||
CreateHeader();
|
||||
|
||||
if (isNew)
|
||||
InitializeExpandedRows();
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Calls <see cref="CreateColumns"/> and initializes the tree view header.</summary>
|
||||
protected void CreateHeader()
|
||||
{
|
||||
var serializedHeaderState = _HeaderState;
|
||||
_HeaderState = new(CreateColumns(position.width - LineHeight));
|
||||
if (MultiColumnHeaderState.CanOverwriteSerializedFields(serializedHeaderState, _HeaderState))
|
||||
MultiColumnHeaderState.OverwriteSerializedFields(serializedHeaderState, _HeaderState);
|
||||
|
||||
_TreeView.multiColumnHeader = new MultiColumnHeader(_HeaderState);
|
||||
}
|
||||
|
||||
/// <summary>Creates the columns for the <see cref="TreeView"/> to use.</summary>
|
||||
protected abstract MultiColumnHeaderState.Column[] CreateColumns(float width);
|
||||
|
||||
/// <summary>Creates a column for the <see cref="TreeView"/> to use.</summary>
|
||||
protected static MultiColumnHeaderState.Column CreateColumn(string name, string tooltip, float width)
|
||||
=> new()
|
||||
{
|
||||
headerContent = new GUIContent(name, tooltip),
|
||||
width = width,
|
||||
allowToggleVisibility = false,
|
||||
canSort = false,
|
||||
};
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual void AddItems(ref int id, TreeViewItem root)
|
||||
{
|
||||
var rootTransform = Root;
|
||||
TreeView.AddItemRecursive(ref id, root, rootTransform);
|
||||
|
||||
var transforms = Transforms;
|
||||
var count = transforms.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var transform = transforms[i];
|
||||
if (!transform.IsChildOf(rootTransform))
|
||||
{
|
||||
AddItem(ref id, root, transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual TreeViewItem AddItem(ref int id, TreeViewItem parent, Transform transform)
|
||||
=> TreeView.AddItem(ref id, parent, transform);
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private void InitializeExpandedRows()
|
||||
{
|
||||
var includedTransforms = Transforms;
|
||||
if (includedTransforms.Count == 0)// If there are no springs, expand everything.
|
||||
{
|
||||
_TreeView.SetExpandedRecursive(TransformTreeView.RootID, true);
|
||||
}
|
||||
else// Otherwise, only expand to show all springs.
|
||||
{
|
||||
var allTransforms = _TreeView.Transforms;
|
||||
for (int i = 0; i < allTransforms.Count; i++)
|
||||
{
|
||||
var transform = allTransforms[i];
|
||||
if (includedTransforms.Contains(transform))
|
||||
{
|
||||
while (transform.parent != null)
|
||||
{
|
||||
transform = transform.parent;
|
||||
var index = allTransforms.LastIndexOf(transform);
|
||||
if (index >= 0)
|
||||
_TreeView.SetExpanded(index, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Draws the GUI of this window.</summary>
|
||||
protected virtual void OnGUI()
|
||||
{
|
||||
if (_TreeView == null ||
|
||||
Data == null ||
|
||||
SourceObject == null)
|
||||
{
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
var area = GUILayoutUtility.GetLastRect();
|
||||
area.width = position.width;
|
||||
|
||||
var searchArea = area;
|
||||
searchArea.xMin += StandardSpacing;
|
||||
searchArea.y += StandardSpacing;
|
||||
searchArea.height = LineHeight;
|
||||
|
||||
area.yMin = searchArea.yMax + StandardSpacing;
|
||||
|
||||
_TreeView.DrawSearchField(searchArea);
|
||||
|
||||
_TreeView.OnGUI(area);
|
||||
|
||||
DoFooterGUI();
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual Transform Root
|
||||
=> AnimancerUtilities.FindRoot(SourceObject.gameObject);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract IList<Transform> Transforms { get; }
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual void BeforeRowGUI(Rect area, TreeViewItem item)
|
||||
{
|
||||
var color = GetRowColor(item);
|
||||
if (color.a > 0)
|
||||
EditorGUI.DrawRect(area, color);
|
||||
}
|
||||
|
||||
/// <summary>Gets the color of a row in the <see cref="TreeView"/>.</summary>
|
||||
protected virtual Color GetRowColor(TreeViewItem item)
|
||||
=> default;
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract void DrawCellGUI(Rect area, int column, int row, TreeViewItem item, ref bool isSelectionClick);
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Draws a <see cref="Transform"/> cell.</summary>
|
||||
public void DrawTransformCellGUI(Rect area, Transform transform)
|
||||
{
|
||||
var enabled = GUI.enabled;
|
||||
if (Event.current.type != EventType.Repaint)
|
||||
GUI.enabled = false;
|
||||
|
||||
var style = EditorStyles.objectField;
|
||||
var contentOffset = style.contentOffset;
|
||||
style.contentOffset = new(0, -1);
|
||||
|
||||
DoObjectFieldGUI(area, GUIContent.none, transform.gameObject, true);
|
||||
|
||||
style.contentOffset = contentOffset;
|
||||
GUI.enabled = enabled;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Draws a cell to toggle whether a particular item is included or not.</summary>
|
||||
public void DrawIsIncludedCellGUI(
|
||||
Rect area,
|
||||
int treeItemID,
|
||||
int definitionIndex,
|
||||
ref bool isSelectionClick)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
var isIncluded = definitionIndex >= 0;
|
||||
isIncluded = GUI.Toggle(area, isIncluded, "");
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
SetIncludedWithSelection(treeItemID, isIncluded);
|
||||
isSelectionClick = false;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static readonly List<int>
|
||||
TreeItemIDs = new();
|
||||
|
||||
private List<int> GetSelectedIDsWith(int treeItemID)
|
||||
{
|
||||
TreeItemIDs.Clear();
|
||||
TreeItemIDs.AddRange(TreeView.GetSelection());
|
||||
if (!TreeItemIDs.Contains(treeItemID))
|
||||
TreeItemIDs.Add(treeItemID);
|
||||
TreeItemIDs.Sort();
|
||||
return TreeItemIDs;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private void SetIncludedWithSelection(
|
||||
int treeItemID,
|
||||
bool isIncluded)
|
||||
{
|
||||
RecordUndo();
|
||||
|
||||
var selected = GetSelectedIDsWith(treeItemID);
|
||||
for (int i = selected.Count - 1; i >= 0; i--)
|
||||
{
|
||||
treeItemID = selected[i];
|
||||
var definitionIndex = GetDefinitionIndex(treeItemID);
|
||||
SetIncluded(treeItemID, definitionIndex, isIncluded);
|
||||
EditorGUIUtility.editingTextField = false;
|
||||
}
|
||||
|
||||
TreeView.Reload();
|
||||
GUIUtility.ExitGUI();
|
||||
}
|
||||
|
||||
/// <summary>Adds or removes an item from the <see cref="SerializedDataEditorWindow{TObject, TData}.Data"/>.</summary>
|
||||
protected abstract void SetIncluded(
|
||||
int treeItemID,
|
||||
int definitionIndex,
|
||||
bool isIncluded);
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Sets the value of a field for all selected items.</summary>
|
||||
protected void SetValue(
|
||||
int treeItemID,
|
||||
Action<int> setValue)
|
||||
{
|
||||
RecordUndo();
|
||||
|
||||
var selected = GetSelectedIDsWith(treeItemID);
|
||||
for (int i = selected.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var definitionIndex = GetDefinitionIndex(selected[i]);
|
||||
if (definitionIndex >= 0)
|
||||
setValue(definitionIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index in the <see cref="SerializedDataEditorWindow{TObject, TData}.Data"/>
|
||||
/// corresponding to a row in the <see cref="TreeView"/>.
|
||||
/// Returns -1 if the row isn't included.
|
||||
/// </summary>
|
||||
protected virtual int GetDefinitionIndex(int treeItemID)
|
||||
{
|
||||
if (_TreeView.Transforms.TryGetObject(treeItemID, out var transform))
|
||||
return Transforms.IndexOf(transform);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static readonly GUIContent
|
||||
RevertLabel = new(
|
||||
"Revert",
|
||||
"Undo all changes made in this window"),
|
||||
ApplyLabel = new(
|
||||
"Apply",
|
||||
"Apply all changes made in this window to the source object"),
|
||||
AutoApplyLabel = new(
|
||||
"Auto Apply",
|
||||
"Immediately apply all changes made in this window to the source object?");
|
||||
|
||||
/// <summary>Draws the GUI at the bottom of this window.</summary>
|
||||
protected virtual void DoFooterGUI()
|
||||
{
|
||||
GUILayout.Space(StandardSpacing);
|
||||
|
||||
var area = GUILayoutUtility.GetRect(0, 0);
|
||||
area.y -= 1;
|
||||
area.height = 1;
|
||||
EditorGUI.DrawRect(area, Grey(0.5f, 0.5f));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
using (new EditorGUI.DisabledScope(Event.current.type != EventType.Repaint))
|
||||
DoObjectFieldGUI("", SourceObject, true);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
DoFooterCenterGUI();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
DoApplyRevertGUI();
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
/// <summary>Draws additional GUI controls in the center of the footer.</summary>
|
||||
protected virtual void DoFooterCenterGUI() { }
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Revert()
|
||||
{
|
||||
base.Revert();
|
||||
|
||||
_TreeView.Reload();
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private void ReloadTreeView()
|
||||
=> TreeView.Reload();
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b4b9d939f0ae08479831c5be6144e90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animancer.Editor
|
||||
{
|
||||
/// <summary>[Editor-Only] A <see cref="PropertyDrawer"/> for <see cref="WeightedMaskLayersDefinition"/> fields.</summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Editor/WeightedMaskLayersDefinitionDrawer
|
||||
[CustomPropertyDrawer(typeof(WeightedMaskLayersDefinition), true)]
|
||||
public class WeightedMaskLayersDefinitionDrawer : EditableFieldDrawer
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static readonly Action<SerializedProperty> OnEditTarget = property =>
|
||||
WeightedMaskLayersDefinitionWindow.Open<WeightedMaskLayersDefinitionWindow>(
|
||||
(WeightedMaskLayers)property.serializedObject.targetObject, false);
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void OnGUI(Rect area, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (property.serializedObject.targetObject is WeightedMaskLayers)
|
||||
OnEdit += OnEditTarget;
|
||||
|
||||
base.OnGUI(area, property, label);
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnEdit -= OnEditTarget;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void GetEditButtonLabel(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var transforms = property.FindPropertyRelative(WeightedMaskLayersDefinition.TransformsField);
|
||||
var weights = property.FindPropertyRelative(WeightedMaskLayersDefinition.WeightsField);
|
||||
|
||||
var transformCount = transforms.arraySize;
|
||||
var groupCount = transformCount > 0
|
||||
? weights.arraySize / transformCount
|
||||
: 0;
|
||||
|
||||
label.text = $"Edit [{transformCount} Transforms] x [{groupCount} Groups]";
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58817c0af6d66fc4fbb7081d1ff7b6aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,374 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
#pragma warning disable CS0618 // Type or member is obsolete - Tree View stuff was made generic in Unity 6.2.
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
using static Animancer.Editor.AnimancerGUI;
|
||||
|
||||
namespace Animancer.Editor
|
||||
{
|
||||
/// <summary>An <see cref="TransformTreeWindow{TTarget, TDefinition}"/> for editing spring definitions.</summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Editor/WeightedMaskLayersDefinitionWindow
|
||||
public class WeightedMaskLayersDefinitionWindow :
|
||||
TransformTreeWindow<WeightedMaskLayers, WeightedMaskLayersDefinition>
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private const int
|
||||
TransformColumn = 0,
|
||||
IncludedColumn = 1,
|
||||
FirstGroupColumn = 2,
|
||||
RootMotionWeightsID = -2;
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IList<Transform> Transforms
|
||||
=> Data.Transforms;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override WeightedMaskLayersDefinition SourceData
|
||||
{
|
||||
get
|
||||
{
|
||||
var sourceObject = SourceObject;
|
||||
return sourceObject != null
|
||||
? sourceObject.Definition
|
||||
: null;
|
||||
}
|
||||
set => SourceObject.Definition = value;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override MultiColumnHeaderState.Column[] CreateColumns(float width)
|
||||
{
|
||||
const float TransformWidth = 300;
|
||||
const float GroupWidth = 100;
|
||||
|
||||
var groupCount = Data.GroupCount;
|
||||
var oldColumns = HeaderState?.columns;
|
||||
|
||||
var newColumns = new MultiColumnHeaderState.Column[groupCount + 2];
|
||||
|
||||
int index;
|
||||
if (oldColumns == null)
|
||||
{
|
||||
var tooltip = "Select which objects to control the weight of";
|
||||
|
||||
newColumns[0] = CreateColumn(
|
||||
"Transform",
|
||||
tooltip,
|
||||
TransformWidth);
|
||||
|
||||
var includedColumn = newColumns[1] = CreateColumn(
|
||||
"?",
|
||||
tooltip,
|
||||
LineHeight + StandardSpacing);
|
||||
|
||||
includedColumn.minWidth = includedColumn.maxWidth = includedColumn.width;
|
||||
|
||||
index = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
var copyCount = Math.Min(oldColumns.Length, groupCount + 2);
|
||||
for (int i = 0; i < copyCount; i++)
|
||||
newColumns[i] = oldColumns[i];
|
||||
|
||||
index = copyCount;
|
||||
}
|
||||
|
||||
for (int i = index; i < groupCount + 2; i++)
|
||||
{
|
||||
var groupIndex = i - 2;
|
||||
var name = "Group " + groupIndex.ToStringCached();
|
||||
var tooltip = "The weights for " + name;
|
||||
|
||||
if (groupIndex == 0)
|
||||
{
|
||||
name = "Default " + name;
|
||||
tooltip += " (this group will be applied on startup by default)";
|
||||
}
|
||||
|
||||
newColumns[i] = CreateColumn(
|
||||
name,
|
||||
tooltip,
|
||||
GroupWidth);
|
||||
}
|
||||
|
||||
return newColumns;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void AddItems(ref int id, TreeViewItem root)
|
||||
{
|
||||
root.AddChild(new()
|
||||
{
|
||||
id = RootMotionWeightsID,
|
||||
depth = 0,
|
||||
});
|
||||
|
||||
base.AddItems(ref id, root);
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override Color GetRowColor(TreeViewItem item)
|
||||
{
|
||||
if (!TreeView.Transforms.TryGetObject(item.id, out var transform))
|
||||
return default;
|
||||
|
||||
if (Transforms.IndexOf(transform) < 0)
|
||||
return default;
|
||||
|
||||
return GetChainColor(transform, Transforms, 0.15f);
|
||||
}
|
||||
|
||||
/// <summary>Returns a color based on the name of the `transform`'s highest included parent.</summary>
|
||||
public static Color GetChainColor(Transform transform, IList<Transform> transforms, float alpha)
|
||||
{
|
||||
transform = GetChainRoot(transform, transforms);
|
||||
return GetHashColor(transform.name.GetHashCode(), 1, 1, alpha);
|
||||
}
|
||||
|
||||
/// <summary>Gets the highest parent of `transform` which is included in the `transforms`.</summary>
|
||||
public static Transform GetChainRoot(Transform transform, IList<Transform> transforms)
|
||||
{
|
||||
var parent = transform.parent;
|
||||
while (parent != null)
|
||||
{
|
||||
if (transforms.IndexOf(parent) >= 0)
|
||||
transform = parent;
|
||||
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void DrawCellGUI(Rect area, int column, int row, TreeViewItem item, ref bool isSelectionClick)
|
||||
{
|
||||
if (!TreeView.Transforms.TryGetObject(item.id, out var transform))
|
||||
{
|
||||
if (item.id == RootMotionWeightsID)
|
||||
DrawRootMotionWeightsCellGUI(area, column);
|
||||
return;
|
||||
}
|
||||
|
||||
var definitionIndex = GetDefinitionIndex(item.id);
|
||||
|
||||
switch (column)
|
||||
{
|
||||
case TransformColumn:
|
||||
DrawTransformCellGUI(area, transform);
|
||||
break;
|
||||
|
||||
case IncludedColumn:
|
||||
DrawIsIncludedCellGUI(area, item.id, definitionIndex, ref isSelectionClick);
|
||||
break;
|
||||
|
||||
default:
|
||||
DrawWeightGUI(area, item.id, column - 2, definitionIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static GUIStyle _RootMotionWeightsLabelStyle;
|
||||
|
||||
private static readonly GUIContent RootMotionWeightsLabel = new(
|
||||
"Root Motion Weights",
|
||||
"When a Group is applied to a Layer, this value will multiply the Root Motion output of that layer");
|
||||
|
||||
private void DrawRootMotionWeightsCellGUI(Rect area, int column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case TransformColumn:
|
||||
_RootMotionWeightsLabelStyle ??= new(GUI.skin.label)
|
||||
{
|
||||
alignment = TextAnchor.MiddleRight,
|
||||
};
|
||||
|
||||
area.yMin--;
|
||||
GUI.Label(area, RootMotionWeightsLabel, _RootMotionWeightsLabelStyle);
|
||||
break;
|
||||
|
||||
case IncludedColumn:
|
||||
break;
|
||||
|
||||
default:
|
||||
column -= FirstGroupColumn;
|
||||
if (!Data.RootMotionWeights.TryGet(column, out var weight))
|
||||
break;
|
||||
|
||||
if (DoFloatFieldGUI(area, ref weight))
|
||||
{
|
||||
weight = Mathf.Clamp01(weight);
|
||||
|
||||
var data = RecordUndo();
|
||||
data.Validate();
|
||||
data.RootMotionWeights[column] = weight;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void SetIncluded(
|
||||
int treeItemID,
|
||||
int definitionIndex,
|
||||
bool isIncluded)
|
||||
{
|
||||
var data = RecordUndo();
|
||||
|
||||
if (isIncluded)
|
||||
{
|
||||
if (definitionIndex < 0 &&
|
||||
TreeView.Transforms.TryGetObject(treeItemID, out var transform))
|
||||
{
|
||||
var groupCount = data.GroupCount;
|
||||
|
||||
data.AddTransform(transform);
|
||||
|
||||
if (groupCount != data.GroupCount)
|
||||
CreateHeader();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (definitionIndex >= 0)
|
||||
{
|
||||
data.RemoveTransform(definitionIndex);
|
||||
|
||||
if (data.GroupCount <= 0)
|
||||
CreateHeader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private void DrawWeightGUI(
|
||||
Rect area,
|
||||
int treeItemID,
|
||||
int groupIndex,
|
||||
int transformIndex)
|
||||
{
|
||||
if (transformIndex < 0)
|
||||
return;
|
||||
|
||||
var weight = Data.GetWeight(groupIndex, transformIndex);
|
||||
|
||||
if (float.IsNaN(weight))
|
||||
return;
|
||||
|
||||
if (DoFloatFieldGUI(area, ref weight))
|
||||
{
|
||||
weight = Mathf.Clamp01(weight);
|
||||
|
||||
SetValue(treeItemID, i => RecordUndo().SetWeight(groupIndex, i, weight));
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static bool DoFloatFieldGUI(Rect area, ref float value)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
var style = EditorStyles.numberField;
|
||||
var contentOffset = style.contentOffset;
|
||||
style.contentOffset = new(0, -2);
|
||||
|
||||
value = EditorGUI.FloatField(area, value);
|
||||
|
||||
style.contentOffset = contentOffset;
|
||||
|
||||
return EditorGUI.EndChangeCheck();
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private static readonly GUIContent
|
||||
AddGroupLabel = new(
|
||||
"Add Group",
|
||||
"Add another weight group"),
|
||||
RemoveGroupLabel = new(
|
||||
"Remove Group",
|
||||
"Remove the last weight group");
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void DoFooterCenterGUI()
|
||||
{
|
||||
var hasTransforms = !Data.Transforms.IsNullOrEmpty();
|
||||
GUI.enabled = hasTransforms;
|
||||
|
||||
if (GUILayout.Button(AddGroupLabel))
|
||||
{
|
||||
RecordUndo().GroupCount++;
|
||||
CreateHeader();
|
||||
}
|
||||
|
||||
if (hasTransforms)
|
||||
GUI.enabled = Data.GroupCount > 1;
|
||||
|
||||
if (GUILayout.Button(RemoveGroupLabel))
|
||||
{
|
||||
RecordUndo().GroupCount--;
|
||||
CreateHeader();
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Apply()
|
||||
{
|
||||
base.Apply();
|
||||
CreateHeader();
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Revert()
|
||||
{
|
||||
base.Revert();
|
||||
CreateHeader();
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override WeightedMaskLayersDefinition RecordUndo(string name = "Animancer")
|
||||
{
|
||||
SceneView.RepaintAll();
|
||||
return base.RecordUndo(name);
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5eb9b334dfed14344935be3105cbe826
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2026 Kybernetik //
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace Animancer.Editor
|
||||
{
|
||||
/// <summary>[Editor-Only] A custom GUI for <see cref="WeightedMaskLayers.Fade"/>.</summary>
|
||||
/// https://kybernetik.com.au/animancer/api/Animancer.Editor/WeightedMaskLayersFadeDrawer
|
||||
[CustomGUI(typeof(WeightedMaskLayers.Fade))]
|
||||
public class WeightedMaskLayersFadeDrawer : CustomGUI<WeightedMaskLayers.Fade>
|
||||
{
|
||||
/************************************************************************************************************************/
|
||||
|
||||
private bool _IsExpanded;
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void DoGUI()
|
||||
{
|
||||
_IsExpanded = EditorGUILayout.Foldout(_IsExpanded, "Weighted Mask Layers Fade", true);
|
||||
|
||||
if (_IsExpanded)
|
||||
DoDetailsGUI();
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
|
||||
/// <summary>Draws the GUI for the target's fields.</summary>
|
||||
protected virtual void DoDetailsGUI()
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
Value.ElapsedTime = EditorGUILayout.Slider("Elapsed", Value.ElapsedTime, 0, Value.Duration);
|
||||
|
||||
Value.Duration = EditorGUILayout.FloatField("Duration", Value.Duration);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
/************************************************************************************************************************/
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53026c4d6eb23ee49beac098d7c7a08f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user