CustomToolbarGraphWindow.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using GraphProcessor;
  6. public class CustomToolbarGraphWindow : BaseGraphWindow
  7. {
  8. BaseGraph tmpGraph;
  9. [MenuItem("Window/03 Custom Toolbar")]
  10. public static BaseGraphWindow OpenWithTmpGraph()
  11. {
  12. var graphWindow = CreateWindow< CustomToolbarGraphWindow >();
  13. // When the graph is opened from the window, we don't save the graph to disk
  14. graphWindow.tmpGraph = ScriptableObject.CreateInstance<BaseGraph>();
  15. graphWindow.tmpGraph.hideFlags = HideFlags.HideAndDontSave;
  16. graphWindow.InitializeGraph(graphWindow.tmpGraph);
  17. graphWindow.Show();
  18. return graphWindow;
  19. }
  20. protected override void OnDestroy()
  21. {
  22. graphView?.Dispose();
  23. DestroyImmediate(tmpGraph);
  24. }
  25. protected override void InitializeWindow(BaseGraph graph)
  26. {
  27. titleContent = new GUIContent("Custom Toolbar Graph");
  28. if (graphView == null)
  29. {
  30. graphView = new CustomToolbarGraphView(this);
  31. graphView.Add(new CustomToolbarView(graphView));
  32. }
  33. rootView.Add(graphView);
  34. }
  35. }