MenuItems.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using BansheeEngine;
  5. namespace BansheeEditor
  6. {
  7. /** @addtogroup Window
  8. * @{
  9. */
  10. /// <summary>
  11. /// Contains various menu item callbacks for the main editor menu bar.
  12. /// </summary>
  13. static class MenuItems
  14. {
  15. /// <summary>
  16. /// Adds a camera component to the currently selected scene object.
  17. /// </summary>
  18. [MenuItem("Components/Camera", 7050)]
  19. private static void AddCamera()
  20. {
  21. SceneObject so = Selection.SceneObject;
  22. if (so == null)
  23. return;
  24. UndoRedo.RecordSO(so, false, "Added a Camera component");
  25. Camera cam = so.AddComponent<Camera>();
  26. cam.Main = true;
  27. EditorApplication.SetSceneDirty();
  28. }
  29. /// <summary>
  30. /// Adds a renderable component to the currently selected scene object.
  31. /// </summary>
  32. [MenuItem("Components/Renderable", 7049)]
  33. private static void AddRenderable()
  34. {
  35. SceneObject so = Selection.SceneObject;
  36. if (so == null)
  37. return;
  38. UndoRedo.RecordSO(so, false, "Added a Renderable component");
  39. so.AddComponent<Renderable>();
  40. EditorApplication.SetSceneDirty();
  41. }
  42. /// <summary>
  43. /// Adds a point light component to the currently selected scene object.
  44. /// </summary>
  45. [MenuItem("Components/Point light", 7048)]
  46. private static void AddPointLight()
  47. {
  48. SceneObject so = Selection.SceneObject;
  49. if (so == null)
  50. return;
  51. UndoRedo.RecordSO(so, false, "Added a Light component");
  52. Light light = so.AddComponent<Light>();
  53. light.Type = LightType.Point;
  54. EditorApplication.SetSceneDirty();
  55. }
  56. /// <summary>
  57. /// Adds a spot light component to the currently selected scene object.
  58. /// </summary>
  59. [MenuItem("Components/Spot light", 7047)]
  60. private static void AddSpotLight()
  61. {
  62. SceneObject so = Selection.SceneObject;
  63. if (so == null)
  64. return;
  65. UndoRedo.RecordSO(so, false, "Added a Light component");
  66. Light light = so.AddComponent<Light>();
  67. light.Type = LightType.Spot;
  68. EditorApplication.SetSceneDirty();
  69. }
  70. /// <summary>
  71. /// Adds a directional light component to the currently selected scene object.
  72. /// </summary>
  73. [MenuItem("Components/Directional light", 7046)]
  74. private static void AddDirectionalLight()
  75. {
  76. SceneObject so = Selection.SceneObject;
  77. if (so == null)
  78. return;
  79. UndoRedo.RecordSO(so, false, "Added a Light component");
  80. Light light = so.AddComponent<Light>();
  81. light.Type = LightType.Directional;
  82. EditorApplication.SetSceneDirty();
  83. }
  84. /// <summary>
  85. /// Adds a GUI widget component to the currently selected scene object.
  86. /// </summary>
  87. [MenuItem("Components/GUI widget", 7045)]
  88. private static void AddGUIWidget()
  89. {
  90. SceneObject so = Selection.SceneObject;
  91. if (so == null)
  92. return;
  93. UndoRedo.RecordSO(so, false, "Added a GUIWidget component");
  94. so.AddComponent<GUIWidget>();
  95. EditorApplication.SetSceneDirty();
  96. }
  97. /// <summary>
  98. /// Adds a BoxCollider component to the currently selected scene object.
  99. /// </summary>
  100. [MenuItem("Components/Physics/Box collider", 7044)]
  101. private static void AddBoxCollider()
  102. {
  103. SceneObject so = Selection.SceneObject;
  104. if (so == null)
  105. {
  106. so = UndoRedo.CreateSO("BoxCollider", "New scene object");
  107. Selection.SceneObject = so;
  108. FocusOnHierarchyOrScene();
  109. }
  110. UndoRedo.RecordSO(so, false, "Added a BoxCollider component");
  111. so.AddComponent<BoxCollider>();
  112. EditorApplication.SetSceneDirty();
  113. }
  114. /// <summary>
  115. /// Adds a SphereCollider component to the currently selected scene object.
  116. /// </summary>
  117. [MenuItem("Components/Physics/Sphere collider", 7043)]
  118. private static void AddSphereCollider()
  119. {
  120. SceneObject so = Selection.SceneObject;
  121. if (so == null)
  122. {
  123. so = UndoRedo.CreateSO("SphereCollider", "New scene object");
  124. Selection.SceneObject = so;
  125. FocusOnHierarchyOrScene();
  126. }
  127. UndoRedo.RecordSO(so, false, "Added a SphereCollider component");
  128. so.AddComponent<SphereCollider>();
  129. EditorApplication.SetSceneDirty();
  130. }
  131. /// <summary>
  132. /// Adds a CapsuleCollider component to the currently selected scene object.
  133. /// </summary>
  134. [MenuItem("Components/Physics/Capsule collider", 7042)]
  135. private static void AddCapsuleCollider()
  136. {
  137. SceneObject so = Selection.SceneObject;
  138. if (so == null)
  139. {
  140. so = UndoRedo.CreateSO("CapsuleCollider", "New scene object");
  141. Selection.SceneObject = so;
  142. FocusOnHierarchyOrScene();
  143. }
  144. UndoRedo.RecordSO(so, false, "Added a CapsuleCollider component");
  145. so.AddComponent<CapsuleCollider>();
  146. EditorApplication.SetSceneDirty();
  147. }
  148. /// <summary>
  149. /// Adds a MeshCollider component to the currently selected scene object.
  150. /// </summary>
  151. [MenuItem("Components/Physics/Mesh collider", 7041)]
  152. private static void AddMeshCollider()
  153. {
  154. SceneObject so = Selection.SceneObject;
  155. if (so == null)
  156. {
  157. so = UndoRedo.CreateSO("MeshCollider", "New scene object");
  158. Selection.SceneObject = so;
  159. FocusOnHierarchyOrScene();
  160. }
  161. UndoRedo.RecordSO(so, false, "Added a MeshCollider component");
  162. so.AddComponent<MeshCollider>();
  163. EditorApplication.SetSceneDirty();
  164. }
  165. /// <summary>
  166. /// Adds a PlaneCollider component to the currently selected scene object.
  167. /// </summary>
  168. [MenuItem("Components/Physics/Plane collider", 7040)]
  169. private static void AddPlaneCollider()
  170. {
  171. SceneObject so = Selection.SceneObject;
  172. if (so == null)
  173. {
  174. so = UndoRedo.CreateSO("PlaneCollider", "New scene object");
  175. Selection.SceneObject = so;
  176. FocusOnHierarchyOrScene();
  177. }
  178. UndoRedo.RecordSO(so, false, "Added a PlaneCollider component");
  179. so.AddComponent<PlaneCollider>();
  180. EditorApplication.SetSceneDirty();
  181. }
  182. /// <summary>
  183. /// Adds a Rigidbody component to the currently selected scene object.
  184. /// </summary>
  185. [MenuItem("Components/Physics/Rigidbody", 7039, true)]
  186. private static void AddRigidbody()
  187. {
  188. SceneObject so = Selection.SceneObject;
  189. if (so == null)
  190. {
  191. so = UndoRedo.CreateSO("Rigidbody", "New scene object");
  192. Selection.SceneObject = so;
  193. FocusOnHierarchyOrScene();
  194. }
  195. UndoRedo.RecordSO(so, false, "Added a Rigidbody component");
  196. so.AddComponent<Rigidbody>();
  197. EditorApplication.SetSceneDirty();
  198. }
  199. /// <summary>
  200. /// Adds a CharacterController component to the currently selected scene object.
  201. /// </summary>
  202. [MenuItem("Components/Physics/Character controller", 7038)]
  203. private static void AddCharacterController()
  204. {
  205. SceneObject so = Selection.SceneObject;
  206. if (so == null)
  207. {
  208. so = UndoRedo.CreateSO("CharacterController", "New scene object");
  209. Selection.SceneObject = so;
  210. FocusOnHierarchyOrScene();
  211. }
  212. UndoRedo.RecordSO(so, false, "Added a CharacterController component");
  213. so.AddComponent<CharacterController>();
  214. EditorApplication.SetSceneDirty();
  215. }
  216. /// <summary>
  217. /// Adds a FixedJoint component to the currently selected scene object.
  218. /// </summary>
  219. [MenuItem("Components/Physics/Fixed joint", 7037, true)]
  220. private static void AddFixedJoint()
  221. {
  222. SceneObject so = Selection.SceneObject;
  223. if (so == null)
  224. {
  225. so = UndoRedo.CreateSO("FixedJoint", "New scene object");
  226. Selection.SceneObject = so;
  227. FocusOnHierarchyOrScene();
  228. }
  229. UndoRedo.RecordSO(so, false, "Added a FixedJoint component");
  230. so.AddComponent<FixedJoint>();
  231. EditorApplication.SetSceneDirty();
  232. }
  233. /// <summary>
  234. /// Adds a DistanceJoint component to the currently selected scene object.
  235. /// </summary>
  236. [MenuItem("Components/Physics/Distance joint", 7036)]
  237. private static void AddDistanceJoint()
  238. {
  239. SceneObject so = Selection.SceneObject;
  240. if (so == null)
  241. {
  242. so = UndoRedo.CreateSO("DistanceJoint", "New scene object");
  243. Selection.SceneObject = so;
  244. FocusOnHierarchyOrScene();
  245. }
  246. UndoRedo.RecordSO(so, false, "Added a DistanceJoint component");
  247. so.AddComponent<DistanceJoint>();
  248. EditorApplication.SetSceneDirty();
  249. }
  250. /// <summary>
  251. /// Adds a HingeJoint component to the currently selected scene object.
  252. /// </summary>
  253. [MenuItem("Components/Physics/Hinge joint", 7035)]
  254. private static void AddHingeJoint()
  255. {
  256. SceneObject so = Selection.SceneObject;
  257. if (so == null)
  258. {
  259. so = UndoRedo.CreateSO("HingeJoint", "New scene object");
  260. Selection.SceneObject = so;
  261. FocusOnHierarchyOrScene();
  262. }
  263. UndoRedo.RecordSO(so, false, "Added a HingeJoint component");
  264. so.AddComponent<HingeJoint>();
  265. EditorApplication.SetSceneDirty();
  266. }
  267. /// <summary>
  268. /// Adds a SphericalJoint component to the currently selected scene object.
  269. /// </summary>
  270. [MenuItem("Components/Physics/Spherical joint", 7034)]
  271. private static void AddSphericalJoint()
  272. {
  273. SceneObject so = Selection.SceneObject;
  274. if (so == null)
  275. {
  276. so = UndoRedo.CreateSO("SphericalJoint", "New scene object");
  277. Selection.SceneObject = so;
  278. FocusOnHierarchyOrScene();
  279. }
  280. UndoRedo.RecordSO(so, false, "Added a SphericalJoint component");
  281. so.AddComponent<SphericalJoint>();
  282. EditorApplication.SetSceneDirty();
  283. }
  284. /// <summary>
  285. /// Adds a SliderJoint component to the currently selected scene object.
  286. /// </summary>
  287. [MenuItem("Components/Physics/Slider joint", 7032)]
  288. private static void AddSliderJoint()
  289. {
  290. SceneObject so = Selection.SceneObject;
  291. if (so == null)
  292. {
  293. so = UndoRedo.CreateSO("SliderJoint", "New scene object");
  294. Selection.SceneObject = so;
  295. FocusOnHierarchyOrScene();
  296. }
  297. UndoRedo.RecordSO(so, false, "Added a SliderJoint component");
  298. so.AddComponent<SliderJoint>();
  299. EditorApplication.SetSceneDirty();
  300. }
  301. /// <summary>
  302. /// Adds a D6Joint component to the currently selected scene object.
  303. /// </summary>
  304. [MenuItem("Components/Physics/D6 joint", 7032)]
  305. private static void AddD6Joint()
  306. {
  307. SceneObject so = Selection.SceneObject;
  308. if (so == null)
  309. {
  310. so = UndoRedo.CreateSO("D6Joint", "New scene object");
  311. Selection.SceneObject = so;
  312. FocusOnHierarchyOrScene();
  313. }
  314. UndoRedo.RecordSO(so, false, "Added a D6Joint component");
  315. so.AddComponent<D6Joint>();
  316. EditorApplication.SetSceneDirty();
  317. }
  318. /// <summary>
  319. /// Creates a new empty scene object.
  320. /// </summary>
  321. [MenuItem("Scene Objects/Scene Object", 8051)]
  322. [ToolbarItem("SceneObject", ToolbarIcon.NewSceneObject, "Creates a new empty scene object", 1601, true)]
  323. private static void AddEmptySO()
  324. {
  325. SceneObject so = UndoRedo.CreateSO("SceneObject", "New scene object");
  326. Selection.SceneObject = so;
  327. FocusOnHierarchyOrScene();
  328. EditorApplication.SetSceneDirty();
  329. }
  330. /// <summary>
  331. /// Creates a new scene object with a camera component.
  332. /// </summary>
  333. [MenuItem("Scene Objects/Camera", 8050)]
  334. [ToolbarItem("Camera", ToolbarIcon.NewCamera, "New camera", 1600, false)]
  335. private static void AddCameraSO()
  336. {
  337. SceneObject so = UndoRedo.CreateSO("Camera", "Created a Camera");
  338. Camera cam = so.AddComponent<Camera>();
  339. cam.Main = true;
  340. Selection.SceneObject = so;
  341. FocusOnHierarchyOrScene();
  342. EditorApplication.SetSceneDirty();
  343. }
  344. /// <summary>
  345. /// Creates a new scene object with a renderable component.
  346. /// </summary>
  347. [MenuItem("Scene Objects/Renderable", 8049)]
  348. [ToolbarItem("Renderable", ToolbarIcon.NewRenderable, "New renderable", 1599)]
  349. private static void AddRenderableSO()
  350. {
  351. SceneObject so = UndoRedo.CreateSO("Renderable", "Created a Renderable");
  352. so.AddComponent<Renderable>();
  353. Selection.SceneObject = so;
  354. FocusOnHierarchyOrScene();
  355. EditorApplication.SetSceneDirty();
  356. }
  357. /// <summary>
  358. /// Creates a new scene object with a point light component.
  359. /// </summary>
  360. [MenuItem("Scene Objects/Point light", 8048)]
  361. [ToolbarItem("Point light", ToolbarIcon.NewPointLight, "New point light", 1598)]
  362. private static void AddPointLightSO()
  363. {
  364. SceneObject so = UndoRedo.CreateSO("Point light", "Created a Light");
  365. Light light = so.AddComponent<Light>();
  366. light.Type = LightType.Point;
  367. Selection.SceneObject = so;
  368. FocusOnHierarchyOrScene();
  369. EditorApplication.SetSceneDirty();
  370. }
  371. /// <summary>
  372. /// Creates a new scene object with a spot light component.
  373. /// </summary>
  374. [MenuItem("Scene Objects/Spot light", 8047)]
  375. [ToolbarItem("Spot light", ToolbarIcon.NewSpotLight, "New spot light", 1597)]
  376. private static void AddSpotLightSO()
  377. {
  378. SceneObject so = UndoRedo.CreateSO("Spot light", "Created a Light");
  379. Light light = so.AddComponent<Light>();
  380. light.Type = LightType.Spot;
  381. Selection.SceneObject = so;
  382. FocusOnHierarchyOrScene();
  383. EditorApplication.SetSceneDirty();
  384. }
  385. /// <summary>
  386. /// Creates a new scene object with a directional light component.
  387. /// </summary>
  388. [MenuItem("Scene Objects/Directional light", 8046)]
  389. [ToolbarItem("Directional light", ToolbarIcon.NewDirLight, "New directional light", 1596)]
  390. private static void AddDirectionalLightSO()
  391. {
  392. SceneObject so = UndoRedo.CreateSO("Directional light", "Created a Light");
  393. Light light = so.AddComponent<Light>();
  394. light.Type = LightType.Directional;
  395. Selection.SceneObject = so;
  396. FocusOnHierarchyOrScene();
  397. EditorApplication.SetSceneDirty();
  398. }
  399. /// <summary>
  400. /// Creates a new scene object with a GUI widget component.
  401. /// </summary>
  402. [MenuItem("Scene Objects/GUI widget", 8045)]
  403. private static void AddGUIWidgetSO()
  404. {
  405. SceneObject so = UndoRedo.CreateSO("GUIWidget", "Created a GUIWidget");
  406. so.AddComponent<GUIWidget>();
  407. Selection.SceneObject = so;
  408. FocusOnHierarchyOrScene();
  409. EditorApplication.SetSceneDirty();
  410. }
  411. /// <summary>
  412. /// Creates a new scene object with a box primitive.
  413. /// </summary>
  414. [MenuItem("Scene Objects/3D primitives/Box", 8100)]
  415. [ToolbarItem("Cube", ToolbarIcon.NewCube, "Creates a scene object with a box primitive", 1700, true)]
  416. private static void Add3DBox()
  417. {
  418. SceneObject so = UndoRedo.CreateSO("Box", "Created a box");
  419. Renderable renderable = so.AddComponent<Renderable>();
  420. renderable.Mesh = Builtin.Box;
  421. Selection.SceneObject = so;
  422. FocusOnHierarchyOrScene();
  423. EditorApplication.SetSceneDirty();
  424. }
  425. /// <summary>
  426. /// Creates a new scene object with a sphere primitive.
  427. /// </summary>
  428. [MenuItem("Scene Objects/3D primitives/Sphere", 8099)]
  429. [ToolbarItem("Sphere", ToolbarIcon.NewSphere, "Creates a scene object with a sphere primitive", 1699)]
  430. private static void Add3DSphere()
  431. {
  432. SceneObject so = UndoRedo.CreateSO("Sphere", "Created a sphere");
  433. Renderable renderable = so.AddComponent<Renderable>();
  434. renderable.Mesh = Builtin.Sphere;
  435. Selection.SceneObject = so;
  436. FocusOnHierarchyOrScene();
  437. EditorApplication.SetSceneDirty();
  438. }
  439. /// <summary>
  440. /// Creates a new scene object with a cone primitive.
  441. /// </summary>
  442. [MenuItem("Scene Objects/3D primitives/Cone", 8098)]
  443. [ToolbarItem("Cone", ToolbarIcon.NewCone, "Creates a scene object with a cone primitive", 1698)]
  444. private static void Add3DCone()
  445. {
  446. SceneObject so = UndoRedo.CreateSO("Cone", "Created a cone");
  447. Renderable renderable = so.AddComponent<Renderable>();
  448. renderable.Mesh = Builtin.Cone;
  449. Selection.SceneObject = so;
  450. FocusOnHierarchyOrScene();
  451. EditorApplication.SetSceneDirty();
  452. }
  453. /// <summary>
  454. /// Creates a new scene object with a quad primitive.
  455. /// </summary>
  456. [MenuItem("Scene Objects/3D primitives/Quad", 8097)]
  457. [ToolbarItem("Quad", ToolbarIcon.NewQuad, "Creates a scene object with a quad primitive", 1697)]
  458. private static void Add3DQuad()
  459. {
  460. SceneObject so = UndoRedo.CreateSO("Quad", "Created a quad");
  461. Renderable renderable = so.AddComponent<Renderable>();
  462. renderable.Mesh = Builtin.Quad;
  463. Selection.SceneObject = so;
  464. FocusOnHierarchyOrScene();
  465. EditorApplication.SetSceneDirty();
  466. }
  467. /// <summary>
  468. /// Creates a new scene object with a disc primitive.
  469. /// </summary>
  470. [MenuItem("Scene Objects/3D primitives/Disc", 8096)]
  471. private static void Add3DDisc()
  472. {
  473. SceneObject so = UndoRedo.CreateSO("Disc", "Created a disc");
  474. Renderable renderable = so.AddComponent<Renderable>();
  475. renderable.Mesh = Builtin.Disc;
  476. Selection.SceneObject = so;
  477. FocusOnHierarchyOrScene();
  478. EditorApplication.SetSceneDirty();
  479. }
  480. /// <summary>
  481. /// Applies changes from the prefab instance to the prefab resource.
  482. /// </summary>
  483. [MenuItem("Scene Objects/Apply prefab", 8025, true)]
  484. private static void ApplyPrefab()
  485. {
  486. SceneObject so = Selection.SceneObject;
  487. if (so == null)
  488. return;
  489. PrefabUtility.ApplyPrefab(so);
  490. }
  491. /// <summary>
  492. /// Reverts a prefab instance to the original state of its prefab.
  493. /// </summary>
  494. [MenuItem("Scene Objects/Revert to prefab", 8024)]
  495. private static void RevertToPrefab()
  496. {
  497. SceneObject so = Selection.SceneObject;
  498. if (so == null)
  499. return;
  500. UndoRedo.RecordSO(so, true, "Reverting \"" + so.Name + "\" to prefab.");
  501. PrefabUtility.RevertPrefab(so);
  502. EditorApplication.SetSceneDirty();
  503. }
  504. /// <summary>
  505. /// Breaks a link between a prefab and its instance.
  506. /// </summary>
  507. [MenuItem("Scene Objects/Break prefab link", 8023)]
  508. private static void BreakPrefabLink()
  509. {
  510. SceneObject so = Selection.SceneObject;
  511. if (so == null)
  512. return;
  513. UndoRedo.BreakPrefab(so, "Breaking prefab link for " + so.Name);
  514. EditorApplication.SetSceneDirty();
  515. }
  516. /// <summary>
  517. /// Cuts the currently selected scene object or resource.
  518. /// </summary>
  519. [MenuItem("Edit/Cut", 9450, true)]
  520. public static void Cut()
  521. {
  522. EditorApplication.TriggerGlobalShortcut(EditorApplication.CutKey);
  523. }
  524. /// <summary>
  525. /// Copies the currently selected scene object or resource.
  526. /// </summary>
  527. [MenuItem("Edit/Copy", 9449)]
  528. public static void Copy()
  529. {
  530. EditorApplication.TriggerGlobalShortcut(EditorApplication.CopyKey);
  531. }
  532. /// <summary>
  533. /// Pastes the scene objects or resources that were previously cut or copied.
  534. /// </summary>
  535. [MenuItem("Edit/Paste", 9448)]
  536. public static void Paste()
  537. {
  538. EditorApplication.TriggerGlobalShortcut(EditorApplication.PasteKey);
  539. }
  540. /// <summary>
  541. /// Deletes currently selected scene objects or resources.
  542. /// </summary>
  543. [MenuItem("Edit/Delete", 9447)]
  544. public static void Delete()
  545. {
  546. EditorApplication.TriggerGlobalShortcut(EditorApplication.DeleteKey);
  547. }
  548. /// <summary>
  549. /// Duplicates currently selected scene objects or resources.
  550. /// </summary>
  551. [MenuItem("Edit/Duplicate", 9446)]
  552. public static void Duplicate()
  553. {
  554. EditorApplication.TriggerGlobalShortcut(EditorApplication.DuplicateKey);
  555. }
  556. /// <summary>
  557. /// Sets keyboard focus to the Hierarchy or Scene windows if open.
  558. /// </summary>
  559. private static void FocusOnHierarchyOrScene()
  560. {
  561. HierarchyWindow hierarchyWindow = EditorWindow.GetWindow<HierarchyWindow>();
  562. if (hierarchyWindow != null)
  563. {
  564. hierarchyWindow.HasFocus = true;
  565. return;
  566. }
  567. SceneWindow sceneWindow = EditorWindow.GetWindow<SceneWindow>();
  568. if (sceneWindow != null)
  569. sceneWindow.HasFocus = true;
  570. }
  571. }
  572. /** @} */
  573. }