MenuItems.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BansheeEngine;
  7. namespace BansheeEditor
  8. {
  9. /// <summary>
  10. /// Contains various menu item callbacks for the main editor menu bar.
  11. /// </summary>
  12. static class MenuItems
  13. {
  14. [MenuItem("Components/Camera", 50)]
  15. private static void AddCamera()
  16. {
  17. SceneObject so = Selection.sceneObject;
  18. if (so == null)
  19. return;
  20. UndoRedo.RecordSO(so, "Added a Camera component");
  21. so.AddComponent<Camera>();
  22. }
  23. [MenuItem("Components/Renderable", 49)]
  24. private static void AddRenderable()
  25. {
  26. SceneObject so = Selection.sceneObject;
  27. if (so == null)
  28. return;
  29. UndoRedo.RecordSO(so, "Added a Renderable component");
  30. so.AddComponent<Renderable>();
  31. }
  32. [MenuItem("Components/Point light", 48)]
  33. private static void AddPointLight()
  34. {
  35. SceneObject so = Selection.sceneObject;
  36. if (so == null)
  37. return;
  38. UndoRedo.RecordSO(so, "Added a Light component");
  39. Light light = so.AddComponent<Light>();
  40. light.Type = LightType.Point;
  41. }
  42. [MenuItem("Components/Spot light", 47)]
  43. private static void AddSpotLight()
  44. {
  45. SceneObject so = Selection.sceneObject;
  46. if (so == null)
  47. return;
  48. UndoRedo.RecordSO(so, "Added a Light component");
  49. Light light = so.AddComponent<Light>();
  50. light.Type = LightType.Spot;
  51. }
  52. [MenuItem("Components/Directional light", 46)]
  53. private static void AddDirectionalLight()
  54. {
  55. SceneObject so = Selection.sceneObject;
  56. if (so == null)
  57. return;
  58. UndoRedo.RecordSO(so, "Added a Light component");
  59. Light light = so.AddComponent<Light>();
  60. light.Type = LightType.Directional;
  61. }
  62. [MenuItem("Scene Objects/Camera", 50)]
  63. private static void AddCameraSO()
  64. {
  65. SceneObject so = UndoRedo.CreateSO("Camera", "Created a Camera");
  66. so.AddComponent<Camera>();
  67. Selection.sceneObject = so;
  68. }
  69. [MenuItem("Scene Objects/Renderable", 49)]
  70. private static void AddRenderableSO()
  71. {
  72. SceneObject so = UndoRedo.CreateSO("Renderable", "Created a Renderable");
  73. so.AddComponent<Renderable>();
  74. Selection.sceneObject = so;
  75. }
  76. [MenuItem("Scene Objects/Point light", 48)]
  77. private static void AddPointLightSO()
  78. {
  79. SceneObject so = UndoRedo.CreateSO("Point light", "Created a Light");
  80. Light light = so.AddComponent<Light>();
  81. light.Type = LightType.Point;
  82. Selection.sceneObject = so;
  83. }
  84. [MenuItem("Scene Objects/Spot light", 47)]
  85. private static void AddSpotLightSO()
  86. {
  87. SceneObject so = UndoRedo.CreateSO("Spot light", "Created a Light");
  88. Light light = so.AddComponent<Light>();
  89. light.Type = LightType.Spot;
  90. Selection.sceneObject = so;
  91. }
  92. [MenuItem("Scene Objects/Directional light", 46)]
  93. private static void AddDirectionalLightSO()
  94. {
  95. SceneObject so = UndoRedo.CreateSO("Directional light", "Created a Light");
  96. Light light = so.AddComponent<Light>();
  97. light.Type = LightType.Directional;
  98. Selection.sceneObject = so;
  99. }
  100. [MenuItem("Scene Objects/3D primitives/Box", 100)]
  101. private static void Add3DBox()
  102. {
  103. SceneObject so = UndoRedo.CreateSO("Box", "Created a box");
  104. Renderable renderable = so.AddComponent<Renderable>();
  105. renderable.Mesh = Builtin.Box;
  106. Selection.sceneObject = so;
  107. }
  108. [MenuItem("Scene Objects/3D primitives/Sphere", 99)]
  109. private static void Add3DSphere()
  110. {
  111. SceneObject so = UndoRedo.CreateSO("Sphere", "Created a sphere");
  112. Renderable renderable = so.AddComponent<Renderable>();
  113. renderable.Mesh = Builtin.Sphere;
  114. Selection.sceneObject = so;
  115. }
  116. [MenuItem("Scene Objects/3D primitives/Cone", 98)]
  117. private static void Add3DCone()
  118. {
  119. SceneObject so = UndoRedo.CreateSO("Cone", "Created a cone");
  120. Renderable renderable = so.AddComponent<Renderable>();
  121. renderable.Mesh = Builtin.Cone;
  122. Selection.sceneObject = so;
  123. }
  124. [MenuItem("Scene Objects/3D primitives/Quad", 97)]
  125. private static void Add3DQuad()
  126. {
  127. SceneObject so = UndoRedo.CreateSO("Quad", "Created a quad");
  128. Renderable renderable = so.AddComponent<Renderable>();
  129. renderable.Mesh = Builtin.Quad;
  130. Selection.sceneObject = so;
  131. }
  132. [MenuItem("Scene Objects/3D primitives/Disc", 96)]
  133. private static void Add3DDisc()
  134. {
  135. SceneObject so = UndoRedo.CreateSO("Disc", "Created a disc");
  136. Renderable renderable = so.AddComponent<Renderable>();
  137. renderable.Mesh = Builtin.Disc;
  138. Selection.sceneObject = so;
  139. }
  140. }
  141. }