From 242978e260c40f2d3559fb8d5263ffd926f38910 Mon Sep 17 00:00:00 2001 From: "MSA.i" Date: Mon, 30 Mar 2026 11:31:14 +0900 Subject: [PATCH 1/2] Add a mode to filter by key --- Editor/CCKProcessTracer.cs | 19 ++++++ Editor/Connect/ConnectFactory.cs | 2 +- Editor/DisplayUpdater.cs | 4 ++ Editor/Draw/ArrowDrawer.cs | 4 +- Editor/Draw/Button.cs | 1 + Editor/Draw/ButtonDrawer.cs | 5 +- Editor/Draw/ObjectFrame.cs | 2 +- Editor/Draw/ObjectFrameDrawer.cs | 3 + Editor/KeyFilter.cs | 108 +++++++++++++++++++++++++++++++ Editor/KeyFilter.cs.meta | 2 + 10 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 Editor/KeyFilter.cs create mode 100644 Editor/KeyFilter.cs.meta diff --git a/Editor/CCKProcessTracer.cs b/Editor/CCKProcessTracer.cs index 8f68fd6..cf99df6 100644 --- a/Editor/CCKProcessTracer.cs +++ b/Editor/CCKProcessTracer.cs @@ -32,6 +32,25 @@ void OnGUI() ProcessObjectFactory.displaySelectionOnly = GUI.Toggle(new Rect(position.size.x - 150, 60, 150, 30), ProcessObjectFactory.displaySelectionOnly, "Display Selection Only"); + var prevEnabled = KeyFilter.enabled; + KeyFilter.enabled = GUI.Toggle(new Rect(position.size.x - 150, 90, 150, 30), + KeyFilter.enabled, "Filter by Key"); + + if (KeyFilter.enabled) + { + var prevIndex = KeyFilter.selectedKeyIndex; + KeyFilter.selectedKeyIndex = EditorGUI.Popup( + new Rect(position.size.x - 150, 120, 150, 20), + KeyFilter.selectedKeyIndex, + KeyFilter.keyDisplayNames); + + if (prevIndex != KeyFilter.selectedKeyIndex) + KeyFilter.BuildFilterSets(); + } + + if (prevEnabled != KeyFilter.enabled) + KeyFilter.BuildFilterSets(); + View.Control(); } diff --git a/Editor/Connect/ConnectFactory.cs b/Editor/Connect/ConnectFactory.cs index a2915a4..971bf7b 100644 --- a/Editor/Connect/ConnectFactory.cs +++ b/Editor/Connect/ConnectFactory.cs @@ -76,7 +76,7 @@ public static List Create(List nodes) return connects; } - static string TrimAxis(string key) + public static string TrimAxis(string key) { if (key.EndsWith(".x") || key.EndsWith(".y") || key.EndsWith(".z")) { diff --git a/Editor/DisplayUpdater.cs b/Editor/DisplayUpdater.cs index a4467eb..2fe4f49 100644 --- a/Editor/DisplayUpdater.cs +++ b/Editor/DisplayUpdater.cs @@ -14,8 +14,12 @@ public static void Update() var nodes = NodeFactory.Create(objects); var connects = ConnectFactory.Create(nodes); + KeyFilter.CollectKeyNames(nodes); + ProcessObjectsAligner.Align(objects); ConnectAligner.Align(connects); + + KeyFilter.BuildFilterSets(); } } } diff --git a/Editor/Draw/ArrowDrawer.cs b/Editor/Draw/ArrowDrawer.cs index e27f487..6dca90a 100644 --- a/Editor/Draw/ArrowDrawer.cs +++ b/Editor/Draw/ArrowDrawer.cs @@ -15,7 +15,7 @@ public static void DrawNormalArrow() { foreach (var a in arrows) { - if (!a.highlight) + if (!a.highlight && KeyFilter.IsArrowVisible(a)) DrawArrow(a.from, a.to, Color.gray); } } @@ -24,7 +24,7 @@ public static void DrawHighlightAllow() { foreach (var a in arrows) { - if (a.highlight) + if (a.highlight && KeyFilter.IsArrowVisible(a)) DrawArrow(a.from, a.to, Color.yellow); } } diff --git a/Editor/Draw/Button.cs b/Editor/Draw/Button.cs index 149d1a8..f58a8d8 100644 --- a/Editor/Draw/Button.cs +++ b/Editor/Draw/Button.cs @@ -4,6 +4,7 @@ namespace CCKProcessTracer.Editor public sealed class Button { readonly IButton parent; + public IButton Owner => parent; public Rect rect; public string text; public Color textColor = new Color(0.933f, 0.933f, 0.933f, 1.000f); diff --git a/Editor/Draw/ButtonDrawer.cs b/Editor/Draw/ButtonDrawer.cs index b497ff3..772d8c6 100644 --- a/Editor/Draw/ButtonDrawer.cs +++ b/Editor/Draw/ButtonDrawer.cs @@ -16,13 +16,16 @@ public static void Draw() { foreach (var button in buttons) { + if (!KeyFilter.IsButtonVisible(button.Owner)) + continue; + var scaledRect = new Rect(); var pos = View.ProcessViewPosition(new Vector2(button.rect.x, button.rect.y)); scaledRect.x = pos.x; scaledRect.y = pos.y; scaledRect.width = button.rect.width * View.scale; scaledRect.height = button.rect.height * View.scale; - + var style = new GUIStyle("button"); style.normal.textColor = button.textColor; if (GUI.Button(scaledRect, button.text, style)) diff --git a/Editor/Draw/ObjectFrame.cs b/Editor/Draw/ObjectFrame.cs index 4b39712..3ac91c5 100644 --- a/Editor/Draw/ObjectFrame.cs +++ b/Editor/Draw/ObjectFrame.cs @@ -5,7 +5,7 @@ namespace CCKProcessTracer.Editor public sealed class ObjectFrame : IButton { readonly GameObject gameObject; - readonly ProcessObject processObject; + public readonly ProcessObject processObject; public Rect rect; diff --git a/Editor/Draw/ObjectFrameDrawer.cs b/Editor/Draw/ObjectFrameDrawer.cs index 8c4e376..280d072 100644 --- a/Editor/Draw/ObjectFrameDrawer.cs +++ b/Editor/Draw/ObjectFrameDrawer.cs @@ -16,6 +16,9 @@ public static void Draw() { foreach (var f in objectFrames) { + if (!KeyFilter.IsFrameVisible(f.processObject)) + continue; + Handles.color = Color.gray; Vector3 upLeft = View.ProcessViewPosition(new Vector2(f.rect.xMin, f.rect.yMin)); diff --git a/Editor/KeyFilter.cs b/Editor/KeyFilter.cs new file mode 100644 index 0000000..eb0fe27 --- /dev/null +++ b/Editor/KeyFilter.cs @@ -0,0 +1,108 @@ +using System.Collections.Generic; + +namespace CCKProcessTracer.Editor +{ + public static class KeyFilter + { + public static bool enabled; + public static int selectedKeyIndex; + public static string[] keyDisplayNames = { "All" }; + + static readonly HashSet visibleArrows = new HashSet(); + static readonly HashSet visibleButtonOwners = new HashSet(); + static readonly HashSet visibleProcessObjects = new HashSet(); + + public static bool IsActive => enabled && selectedKeyIndex > 0; + + public static string SelectedKeyName => + IsActive ? keyDisplayNames[selectedKeyIndex] : null; + + public static void CollectKeyNames(List nodes) + { + var keySet = new SortedSet(); + foreach (var node in nodes) + { + foreach (var key in node.useKeys) + { + if (!string.IsNullOrEmpty(key.keyName)) + keySet.Add(ConnectFactory.TrimAxis(key.keyName)); + } + if (!string.IsNullOrEmpty(node.receiveKeyName)) + keySet.Add(ConnectFactory.TrimAxis(node.receiveKeyName)); + } + + var names = new List { "All" }; + names.AddRange(keySet); + keyDisplayNames = names.ToArray(); + + if (selectedKeyIndex >= keyDisplayNames.Length) + selectedKeyIndex = 0; + } + + public static void BuildFilterSets() + { + visibleArrows.Clear(); + visibleButtonOwners.Clear(); + visibleProcessObjects.Clear(); + + if (!IsActive) return; + + var targetKey = SelectedKeyName; + + foreach (var connect in ConnectFactory.connects) + { + if (ConnectFactory.TrimAxis(connect.from.keyName) == targetKey) + { + if (connect.arrow != null) + visibleArrows.Add(connect.arrow); + + visibleButtonOwners.Add(connect.from); + visibleButtonOwners.Add(connect.from.node); + visibleProcessObjects.Add(connect.from.processObject); + + visibleButtonOwners.Add(connect.to); + visibleProcessObjects.Add(connect.to.processObject); + } + } + + foreach (var node in NodeFactory.nodes) + { + foreach (var key in node.useKeys) + { + if (ConnectFactory.TrimAxis(key.keyName) == targetKey) + { + visibleButtonOwners.Add(key); + visibleButtonOwners.Add(node); + visibleProcessObjects.Add(node.processObject); + } + } + if (!string.IsNullOrEmpty(node.receiveKeyName) && + ConnectFactory.TrimAxis(node.receiveKeyName) == targetKey) + { + visibleButtonOwners.Add(node); + visibleProcessObjects.Add(node.processObject); + } + } + } + + public static bool IsArrowVisible(Arrow arrow) + { + if (!IsActive) return true; + return visibleArrows.Contains(arrow); + } + + public static bool IsButtonVisible(IButton owner) + { + if (!IsActive) return true; + if (owner is ObjectFrame frame) + return visibleProcessObjects.Contains(frame.processObject); + return visibleButtonOwners.Contains(owner); + } + + public static bool IsFrameVisible(ProcessObject processObject) + { + if (!IsActive) return true; + return visibleProcessObjects.Contains(processObject); + } + } +} diff --git a/Editor/KeyFilter.cs.meta b/Editor/KeyFilter.cs.meta new file mode 100644 index 0000000..64193be --- /dev/null +++ b/Editor/KeyFilter.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0650a805e6eb7d44e82d7a0f965fe60e \ No newline at end of file From 0fd1eb39b7dacf863752b5e5ec409ccf3ff6ea37 Mon Sep 17 00:00:00 2001 From: "MSA.i" Date: Mon, 30 Mar 2026 11:32:02 +0900 Subject: [PATCH 2/2] Update the version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47dfa76..a9ebb9f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Cluster, Inc.", "name": "mu.cluster.cck-process-tracer", - "version": "1.1.0", + "version": "1.2.0", "displayName": "CCK Process Tracer", "unity": "2021.3", "description": "Visualize CCK Trigger transition",