MenuItems.cs 24 KB

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