diff --git a/Editor/Blocks/OutputCamera/Transform Position to Output Camera.vfxblock b/Editor/Blocks/OutputCamera/Transform Position to Output Camera.vfxblock index 2722a17..55e822b 100644 --- a/Editor/Blocks/OutputCamera/Transform Position to Output Camera.vfxblock +++ b/Editor/Blocks/OutputCamera/Transform Position to Output Camera.vfxblock @@ -20,6 +20,8 @@ VisualEffectResource: m_PreWarmDeltaTime: 0.05 m_PreWarmStepCount: 0 m_InitialEventName: OnPlay + m_InstancingMode: -1 + m_InstancingCapacity: 64 --- !u!114 &114350483966674976 MonoBehaviour: m_ObjectHideFlags: 0 @@ -78,7 +80,7 @@ MonoBehaviour: enumValues: [] descendantCount: 0 m_ImportDependencies: [] - m_GraphVersion: 9 + m_GraphVersion: 11 m_ResourceVersion: 1 m_SubgraphDependencies: - {fileID: 5371698745253816930, guid: 11a2d0a6e693e7248b7df41a4ecd150b, type: 3} @@ -181,6 +183,7 @@ MonoBehaviour: - {fileID: 114350483966674981} m_OutputSlots: [] m_Disabled: 0 + m_ActivationSlot: {fileID: 114350483966675183} attribute: position Composition: 0 Source: 0 @@ -626,7 +629,8 @@ MonoBehaviour: - {fileID: 114350483966675182} m_OutputSlots: - {fileID: 114350483966675176} - m_Subgraph: {fileID: 5371698745253816930, guid: 11a2d0a6e693e7248b7df41a4ecd150b, type: 3} + m_Subgraph: {fileID: 5371698745253816930, guid: 11a2d0a6e693e7248b7df41a4ecd150b, + type: 3} --- !u!114 &114350483966675171 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1051,3 +1055,37 @@ MonoBehaviour: m_Direction: 0 m_LinkedSlots: - {fileID: 114350483966675181} +--- !u!114 &114350483966675183 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b4c11ff25089a324daf359f4b0629b33, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UIIgnoredErrors: [] + m_Parent: {fileID: 0} + m_Children: [] + m_UIPosition: {x: 0, y: 0} + m_UICollapsed: 1 + m_UISuperCollapsed: 0 + m_MasterSlot: {fileID: 114350483966675183} + m_MasterData: + m_Owner: {fileID: 114350483966674980} + m_Value: + m_Type: + m_SerializableType: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + m_SerializableObject: True + m_Space: 2147483647 + m_Property: + name: _vfx_enabled + m_serializedType: + m_SerializableType: System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + m_Direction: 0 + m_LinkedSlots: [] diff --git a/Editor/Debug/VFXDebugEditorWindow.cs b/Editor/Debug/VFXDebugEditorWindow.cs index 357568e..4ebd461 100644 --- a/Editor/Debug/VFXDebugEditorWindow.cs +++ b/Editor/Debug/VFXDebugEditorWindow.cs @@ -414,10 +414,7 @@ private void OnGUI() r.xMin = r.xMax; r.width = 40; if (GUI.Button(r, "Edit", Styles.toolbarButton)) { - if (VFXViewWindow.currentWindow == null) - GetWindow(); - - VFXViewWindow.currentWindow.LoadAsset(entry.asset, entry.component); + VFXViewWindow.GetWindow(entry.asset, true); } } } diff --git a/Editor/Gallery/VFXGraphGalleryWindow.cs b/Editor/Gallery/VFXGraphGalleryWindow.cs index 2770169..ec00bd9 100644 --- a/Editor/Gallery/VFXGraphGalleryWindow.cs +++ b/Editor/Gallery/VFXGraphGalleryWindow.cs @@ -20,18 +20,19 @@ enum WindowMode bool debug = false; Vector2 addPosition; - public static void OpenWindowCreateAsset(string outPath) + internal static void OpenWindowCreateAsset(string outPath) { var window = GetWindow(true, "Create New VFX Asset", true); window.outPath = outPath; window.mode = WindowMode.CreateAsset; } - public static void OpenWindowAddTemplate(Vector2 addPosition) + internal static void OpenWindowAddTemplate(Vector2 addPosition, VFXViewWindow vfxWindow) { var window = GetWindow(true, $"Create New System from Template", true); window.mode = WindowMode.AddNode; window.addPosition = addPosition; + vfxInvokingWindow = vfxWindow; } private void OnEnable() @@ -51,7 +52,7 @@ void SetTitle(string title) Vector2 scroll; Vector2 scrollDesc; - + static VFXViewWindow vfxInvokingWindow; List categories; VFXGraphGalleryTemplate.Template selected; @@ -71,7 +72,6 @@ bool createGameObject } } - void UpdateTemplates() { if (categories == null) @@ -251,7 +251,8 @@ private void OnGUI() if (GUILayout.Button("Add System", GUILayout.Width(100), GUILayout.Height(22)) || pressedReturn) { - VFXViewWindow.currentWindow.graphView.CreateTemplateSystem(AssetDatabase.GetAssetPath(selectedSource), addPosition, null); + vfxInvokingWindow.graphView.CreateTemplateSystem(AssetDatabase.GetAssetPath(selectedSource), addPosition, null); + vfxInvokingWindow = null; Close(); } EditorGUI.EndDisabledGroup(); diff --git a/Editor/Navigator/VFXNavigator.cs b/Editor/Navigator/VFXNavigator.cs index 5a7cc5c..369acbe 100644 --- a/Editor/Navigator/VFXNavigator.cs +++ b/Editor/Navigator/VFXNavigator.cs @@ -112,7 +112,7 @@ void ReloadNavigator() needReloadNavigator = false; } - class VFXNavigatorTreeView : TreeView + class VFXNavigatorTreeView : IMGUI.Controls.TreeView { VFXViewWindow m_Window; VFXView m_VFXView; diff --git a/Extension/VFXGraphExtension.DebugView.cs b/Extension/VFXGraphExtension.DebugView.cs index eb60e4a..d42f347 100644 --- a/Extension/VFXGraphExtension.DebugView.cs +++ b/Extension/VFXGraphExtension.DebugView.cs @@ -12,10 +12,14 @@ static partial class VFXGraphExtension //.DebugView { - static bool debugInfoVisible + static bool GetDebugInfoVisible(VisualEffectAsset asset) { - get { return EditorPrefs.GetBool("VFXGraphExtension.debugInfoVisible", true); } - set { EditorPrefs.SetBool("VFXGraphExtension.debugInfoVisible", value); } + return EditorPrefs.GetBool($"VFXGraphExtension.debugInfoVisible.{asset.name}", true); + } + + static void SetDebugInfoVisible(VisualEffectAsset asset, bool visible) + { + EditorPrefs.SetBool($"VFXGraphExtension.debugInfoVisible.{asset.name}", visible); } static List spawnersToDelete = new List(); @@ -55,40 +59,60 @@ struct SystemDebugInfo public Label memoryLabel; } - static List spawnerDebugInfos; - static List systemDebugInfos; + static Dictionary> spawnerDebugInfos; + static Dictionary> systemDebugInfos; + static Dictionary currentVisualEffectAsset; + static Dictionary> systemNames = new Dictionary>(); + static Dictionary> spawnerNames = new Dictionary>(); - static void ToggleSpawnerStats() + static void ToggleSpawnerStats(object wnd) { - debugInfoVisible = !debugInfoVisible; - UpdateStatsUIElements(); + VFXViewWindow window = (VFXViewWindow)wnd; + var asset = window.displayedResource.asset; + + if(asset != null) + { + bool visible = !GetDebugInfoVisible(asset); + SetDebugInfoVisible(asset, visible); + UpdateStatsUIElements(window); + } } - static void UpdateStatsUIElements() + static void UpdateStatsUIElements(VFXViewWindow window) { - var wnd = VFXViewWindow.currentWindow; - if (wnd == null) + if (window == null) return; - var gv = wnd.graphView; + var gv = window.graphView; if (gv == null || gv.controller == null || gv.controller.model == null) return; if (spawnerDebugInfos == null) - spawnerDebugInfos = new List(); + spawnerDebugInfos = new Dictionary>(); if (systemDebugInfos == null) - systemDebugInfos = new List(); + systemDebugInfos = new Dictionary>(); + + if (currentVisualEffectAsset == null) + currentVisualEffectAsset = new Dictionary(); // Check if asset changed - VisualEffectAsset currentAsset = VFXViewWindow.currentWindow.graphView.controller.model.asset; + VisualEffectAsset currentAsset = window.graphView.controller.model.asset; - if (currentAsset != m_CurrentVisualEffectAsset) + // If window was not registered, register it + if(!currentVisualEffectAsset.ContainsKey(window)) { - spawnerDebugInfos.Clear(); - systemDebugInfos.Clear(); - m_CurrentVisualEffectAsset = currentAsset; + currentVisualEffectAsset.Add(window, currentAsset); + spawnerDebugInfos.Add(window, new List()); + systemDebugInfos.Add(window, new List()); + } + + if (currentAsset != currentVisualEffectAsset[window]) + { + spawnerDebugInfos[window].Clear(); + systemDebugInfos[window].Clear(); + currentVisualEffectAsset[window] = currentAsset; } gv.Query().Build().ForEach((context) => @@ -97,7 +121,7 @@ static void UpdateStatsUIElements() { string name = context.Q