61 lines
2.7 KiB
C#
61 lines
2.7 KiB
C#
using System.Linq;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.FrameAnimation.Editor
|
|
{
|
|
[CustomEditor(typeof(FrameClip))]
|
|
public sealed class FrameClipEditor : UnityEditor.Editor
|
|
{
|
|
public override void OnInspectorGUI()
|
|
{
|
|
var clip = (FrameClip)target;
|
|
var owners = FrameAnimationAssetReferenceIndex.FindGraphsReferencing(clip);
|
|
EditorGUILayout.LabelField(clip.IsImported ? "Imported FrameClip" : "Manual FrameClip", EditorStyles.boldLabel);
|
|
using (new EditorGUI.DisabledScope(true))
|
|
{
|
|
EditorGUILayout.TextField("ID", clip.Id);
|
|
EditorGUILayout.TextField("Display Name", clip.DisplayName);
|
|
EditorGUILayout.FloatField("Speed", clip.Speed);
|
|
EditorGUILayout.EnumPopup("Default End", clip.DefaultEndBehavior);
|
|
EditorGUILayout.IntField("Frames", clip.FrameCount);
|
|
EditorGUILayout.LongField("Total Duration Ms", clip.TotalDurationMs);
|
|
EditorGUILayout.TextField("Storage", AssetDatabase.IsSubAsset(clip) ? "Graph sub-asset" : "External .asset");
|
|
EditorGUILayout.TextField("Source Tag", clip.ImportInfo?.SourceTagName ?? string.Empty);
|
|
EditorGUILayout.Toggle("Missing", clip.ImportInfo?.IsMissingFromSource ?? false);
|
|
}
|
|
if (!AssetDatabase.IsSubAsset(clip) && owners.Count > 1)
|
|
{
|
|
EditorGUILayout.HelpBox(
|
|
"该外部 Manual Clip 被多个 Graph 共享:" + string.Join(", ", owners.Select(graph => graph.name)),
|
|
MessageType.Warning);
|
|
}
|
|
EditorGUILayout.HelpBox(
|
|
"Clip id、帧表和资产所有权操作只能在 Frame Animation Graph Editor 中执行。",
|
|
MessageType.Info);
|
|
if (owners.Count == 0)
|
|
{
|
|
EditorGUILayout.HelpBox("当前没有 FrameAnimationGraph 引用该 Clip。", MessageType.Info);
|
|
}
|
|
else if (owners.Count == 1)
|
|
{
|
|
if (GUILayout.Button("Open Referencing Graph"))
|
|
{
|
|
FrameAnimationGraphEditorWindow.Open(owners[0]);
|
|
}
|
|
}
|
|
else if (GUILayout.Button("Choose Referencing Graph"))
|
|
{
|
|
var menu = new GenericMenu();
|
|
foreach (var owner in owners)
|
|
{
|
|
var captured = owner;
|
|
menu.AddItem(new GUIContent(owner.name), false,
|
|
() => FrameAnimationGraphEditorWindow.Open(captured));
|
|
}
|
|
menu.ShowAsContext();
|
|
}
|
|
}
|
|
}
|
|
}
|