HierarchyWindow.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. /// <summary>
  7. /// Editor window that displays the scene hierarchy tree view, displaying all scene objects in the current scene.
  8. /// </summary>
  9. public class HierarchyWindow : EditorWindow
  10. {
  11. private GUISceneTreeView treeView;
  12. /// <summary>
  13. /// Opens the hierarchy window.
  14. /// </summary>
  15. [MenuItem("Windows/Hierarchy", ButtonModifier.CtrlAlt, ButtonCode.H, 6000)]
  16. private static void OpenHierarchyWindow()
  17. {
  18. OpenWindow<HierarchyWindow>();
  19. }
  20. /// <inheritdoc/>
  21. protected override LocString GetDisplayName()
  22. {
  23. return new LocEdString("Hierarchy");
  24. }
  25. /// <summary>
  26. /// Cuts the currently selected scene object.
  27. /// </summary>
  28. public void CutSelection()
  29. {
  30. treeView.CutSelection();
  31. }
  32. /// <summary>
  33. /// Copies the currently selected scene object.
  34. /// </summary>
  35. public void CopySelection()
  36. {
  37. treeView.CopySelection();
  38. }
  39. /// <summary>
  40. /// Pastes the scene object(s) that were previously cut or copied.
  41. /// </summary>
  42. public void PasteToSelection()
  43. {
  44. treeView.PasteToSelection();
  45. }
  46. /// <summary>
  47. /// Deletes currently selected scene objects.
  48. /// </summary>
  49. public void DeleteSelection()
  50. {
  51. treeView.DeleteSelection();
  52. }
  53. /// <summary>
  54. /// Duplicates currently selected scene objects.
  55. /// </summary>
  56. public void DuplicateSelection()
  57. {
  58. treeView.DuplicateSelection();
  59. }
  60. private void OnInitialize()
  61. {
  62. GUIScrollArea scrollArea = new GUIScrollArea();
  63. GUI.AddElement(scrollArea);
  64. treeView = new GUISceneTreeView(GUIOption.FlexibleHeight(20), GUIOption.FlexibleWidth(20));
  65. scrollArea.Layout.AddElement(treeView);
  66. }
  67. private void OnEditorUpdate()
  68. {
  69. treeView.Update();
  70. }
  71. }
  72. }