feat(frame-animation): 编辑器支持共享 SpriteRect 与 Graph 属性面板
This commit is contained in:
@@ -29,6 +29,8 @@ namespace AibisDream.FrameAnimation.Editor
|
||||
|
||||
[SerializeField] private FrameAnimationGraph graph;
|
||||
private ObjectField graphField;
|
||||
private ToolbarButton graphPropertiesButton;
|
||||
private ToolbarButton graphBreadcrumbButton;
|
||||
private Label dirtyLabel;
|
||||
private Label canvasLabel;
|
||||
private FrameAnimationGraphView graphView;
|
||||
@@ -173,6 +175,13 @@ namespace AibisDream.FrameAnimation.Editor
|
||||
graphField.style.width = 330f;
|
||||
graphField.RegisterValueChangedCallback(evt => SetGraph(evt.newValue as FrameAnimationGraph));
|
||||
toolbar.Add(graphField);
|
||||
graphPropertiesButton = new ToolbarButton(SelectGraphProperties)
|
||||
{
|
||||
name = "graph-properties-button",
|
||||
text = "Graph Properties",
|
||||
tooltip = "查看和编辑当前 Graph 的参数"
|
||||
};
|
||||
toolbar.Add(graphPropertiesButton);
|
||||
toolbar.Add(new ToolbarButton(CreateGraph) { text = "Create" });
|
||||
toolbar.Add(new ToolbarButton(SaveGraph) { text = "Save" });
|
||||
dirtyLabel = new Label();
|
||||
@@ -212,6 +221,15 @@ namespace AibisDream.FrameAnimation.Editor
|
||||
}
|
||||
};
|
||||
var canvasToolbar = new Toolbar();
|
||||
graphBreadcrumbButton = new ToolbarButton(SelectGraphProperties)
|
||||
{
|
||||
name = "graph-breadcrumb-button",
|
||||
text = "Graph",
|
||||
tooltip = "返回当前 Graph 的属性"
|
||||
};
|
||||
graphBreadcrumbButton.style.minWidth = 80f;
|
||||
graphBreadcrumbButton.style.maxWidth = 220f;
|
||||
canvasToolbar.Add(graphBreadcrumbButton);
|
||||
canvasToolbar.Add(new ToolbarButton(ShowAllNodes) { text = "Show All" });
|
||||
flowFocusStatusLabel = new Label("Show All")
|
||||
{
|
||||
@@ -890,6 +908,20 @@ namespace AibisDream.FrameAnimation.Editor
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectGraphProperties()
|
||||
{
|
||||
if (graph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
graphView?.ClearSelection();
|
||||
resourceList?.ClearSelection();
|
||||
multiSelectedNodes = Array.Empty<AnimationNode>();
|
||||
lastSelectedNode = null;
|
||||
SetSelection(new FrameAnimationEditorSelection(FrameAnimationEditorSelectionKind.Graph, graph), false);
|
||||
}
|
||||
|
||||
private void RefreshBrowser()
|
||||
{
|
||||
if (resourceList == null)
|
||||
@@ -1217,6 +1249,7 @@ namespace AibisDream.FrameAnimation.Editor
|
||||
|
||||
private void RefreshCanvasSummary()
|
||||
{
|
||||
RefreshGraphNavigation();
|
||||
if (canvasLabel == null)
|
||||
{
|
||||
return;
|
||||
@@ -1237,6 +1270,25 @@ namespace AibisDream.FrameAnimation.Editor
|
||||
$"当前定位:{located}";
|
||||
}
|
||||
|
||||
private void RefreshGraphNavigation()
|
||||
{
|
||||
var hasGraph = graph != null;
|
||||
graphPropertiesButton?.SetEnabled(hasGraph);
|
||||
graphBreadcrumbButton?.SetEnabled(hasGraph);
|
||||
if (graphBreadcrumbButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var graphName = !hasGraph
|
||||
? "Graph"
|
||||
: string.IsNullOrWhiteSpace(graph.DisplayName) ? graph.Id : graph.DisplayName;
|
||||
graphBreadcrumbButton.text = $"Graph: {graphName}";
|
||||
graphBreadcrumbButton.tooltip = hasGraph
|
||||
? $"查看和编辑 {graphName} 的 Graph 参数"
|
||||
: "未选择 Graph";
|
||||
}
|
||||
|
||||
private static string SelectionName(FrameAnimationEditorSelection selected)
|
||||
{
|
||||
return selected.Value switch
|
||||
@@ -1805,6 +1857,13 @@ namespace AibisDream.FrameAnimation.Editor
|
||||
foreach (var source in importPreview.Sources)
|
||||
{
|
||||
EditorGUILayout.LabelField(source.Source.DisplayName, EditorStyles.boldLabel);
|
||||
if (source.Document != null)
|
||||
{
|
||||
var aliasCount = source.Document.Frames.Count - source.Document.SpriteSlots.Count;
|
||||
EditorGUILayout.LabelField(
|
||||
$"逻辑帧 {source.Document.Frames.Count} · SpriteSlot {source.Document.SpriteSlots.Count} · 共享别名 {aliasCount}",
|
||||
EditorStyles.miniLabel);
|
||||
}
|
||||
if (GUILayout.Button("Locate Source", GUILayout.Width(110f)))
|
||||
{
|
||||
SetSelection(new FrameAnimationEditorSelection(FrameAnimationEditorSelectionKind.Source, source.Source));
|
||||
|
||||
Reference in New Issue
Block a user