| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BansheeEngine;
- namespace BansheeEditor
- {
- /// <summary>
- /// Contains various menu item callbacks for the main editor menu bar.
- /// </summary>
- static class MenuItems
- {
- /// <summary>
- /// Adds a camera component to the currently selected scene object.
- /// </summary>
- [MenuItem("Components/Camera", 7050)]
- private static void AddCamera()
- {
- SceneObject so = Selection.SceneObject;
- if (so == null)
- return;
- UndoRedo.RecordSO(so, false, "Added a Camera component");
- Camera cam = so.AddComponent<Camera>();
- cam.Main = true;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Adds a renderable component to the currently selected scene object.
- /// </summary>
- [MenuItem("Components/Renderable", 7049)]
- private static void AddRenderable()
- {
- SceneObject so = Selection.SceneObject;
- if (so == null)
- return;
- UndoRedo.RecordSO(so, false, "Added a Renderable component");
- so.AddComponent<Renderable>();
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Adds a point light component to the currently selected scene object.
- /// </summary>
- [MenuItem("Components/Point light", 7048)]
- private static void AddPointLight()
- {
- SceneObject so = Selection.SceneObject;
- if (so == null)
- return;
- UndoRedo.RecordSO(so, false, "Added a Light component");
- Light light = so.AddComponent<Light>();
- light.Type = LightType.Point;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Adds a spot light component to the currently selected scene object.
- /// </summary>
- [MenuItem("Components/Spot light", 7047)]
- private static void AddSpotLight()
- {
- SceneObject so = Selection.SceneObject;
- if (so == null)
- return;
- UndoRedo.RecordSO(so, false, "Added a Light component");
- Light light = so.AddComponent<Light>();
- light.Type = LightType.Spot;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Adds a directional light component to the currently selected scene object.
- /// </summary>
- [MenuItem("Components/Directional light", 7046)]
- private static void AddDirectionalLight()
- {
- SceneObject so = Selection.SceneObject;
- if (so == null)
- return;
- UndoRedo.RecordSO(so, false, "Added a Light component");
- Light light = so.AddComponent<Light>();
- light.Type = LightType.Directional;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Adds a GUI widget component to the currently selected scene object.
- /// </summary>
- [MenuItem("Components/GUI widget", 7045)]
- private static void AddGUIWidget()
- {
- SceneObject so = Selection.SceneObject;
- if (so == null)
- return;
- UndoRedo.RecordSO(so, false, "Added a GUIWidget component");
- so.AddComponent<GUIWidget>();
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new empty scene object.
- /// </summary>
- [MenuItem("Scene Objects/Scene Object", 8051)]
- [ToolbarItem("SceneObject", ToolbarIcon.NewSceneObject, "Creates a new empty scene object", 1601, true)]
- private static void AddEmptySO()
- {
- SceneObject so = UndoRedo.CreateSO("SceneObject", "New scene object");
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a camera component.
- /// </summary>
- [MenuItem("Scene Objects/Camera", 8050)]
- [ToolbarItem("Camera", ToolbarIcon.NewCamera, "New camera", 1600, false)]
- private static void AddCameraSO()
- {
- SceneObject so = UndoRedo.CreateSO("Camera", "Created a Camera");
- Camera cam = so.AddComponent<Camera>();
- cam.Main = true;
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a renderable component.
- /// </summary>
- [MenuItem("Scene Objects/Renderable", 8049)]
- [ToolbarItem("Renderable", ToolbarIcon.NewRenderable, "New renderable", 1599)]
- private static void AddRenderableSO()
- {
- SceneObject so = UndoRedo.CreateSO("Renderable", "Created a Renderable");
- so.AddComponent<Renderable>();
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a point light component.
- /// </summary>
- [MenuItem("Scene Objects/Point light", 8048)]
- [ToolbarItem("Point light", ToolbarIcon.NewPointLight, "New point light", 1598)]
- private static void AddPointLightSO()
- {
- SceneObject so = UndoRedo.CreateSO("Point light", "Created a Light");
- Light light = so.AddComponent<Light>();
- light.Type = LightType.Point;
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a spot light component.
- /// </summary>
- [MenuItem("Scene Objects/Spot light", 8047)]
- [ToolbarItem("Spot light", ToolbarIcon.NewSpotLight, "New spot light", 1597)]
- private static void AddSpotLightSO()
- {
- SceneObject so = UndoRedo.CreateSO("Spot light", "Created a Light");
- Light light = so.AddComponent<Light>();
- light.Type = LightType.Spot;
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a directional light component.
- /// </summary>
- [MenuItem("Scene Objects/Directional light", 8046)]
- [ToolbarItem("Directional light", ToolbarIcon.NewDirLight, "New directional light", 1596)]
- private static void AddDirectionalLightSO()
- {
- SceneObject so = UndoRedo.CreateSO("Directional light", "Created a Light");
- Light light = so.AddComponent<Light>();
- light.Type = LightType.Directional;
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a GUI widget component.
- /// </summary>
- [MenuItem("Scene Objects/GUI widget", 8045)]
- private static void AddGUIWidgetSO()
- {
- SceneObject so = UndoRedo.CreateSO("GUIWidget", "Created a GUIWidget");
- so.AddComponent<GUIWidget>();
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a box primitive.
- /// </summary>
- [MenuItem("Scene Objects/3D primitives/Box", 8100)]
- [ToolbarItem("Cube", ToolbarIcon.NewCube, "Creates a scene object with a box primitive", 1700, true)]
- private static void Add3DBox()
- {
- SceneObject so = UndoRedo.CreateSO("Box", "Created a box");
- Renderable renderable = so.AddComponent<Renderable>();
- renderable.Mesh = Builtin.Box;
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a sphere primitive.
- /// </summary>
- [MenuItem("Scene Objects/3D primitives/Sphere", 8099)]
- [ToolbarItem("Sphere", ToolbarIcon.NewSphere, "Creates a scene object with a sphere primitive", 1699)]
- private static void Add3DSphere()
- {
- SceneObject so = UndoRedo.CreateSO("Sphere", "Created a sphere");
- Renderable renderable = so.AddComponent<Renderable>();
- renderable.Mesh = Builtin.Sphere;
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a cone primitive.
- /// </summary>
- [MenuItem("Scene Objects/3D primitives/Cone", 8098)]
- [ToolbarItem("Cone", ToolbarIcon.NewCone, "Creates a scene object with a cone primitive", 1698)]
- private static void Add3DCone()
- {
- SceneObject so = UndoRedo.CreateSO("Cone", "Created a cone");
- Renderable renderable = so.AddComponent<Renderable>();
- renderable.Mesh = Builtin.Cone;
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a quad primitive.
- /// </summary>
- [MenuItem("Scene Objects/3D primitives/Quad", 8097)]
- [ToolbarItem("Quad", ToolbarIcon.NewQuad, "Creates a scene object with a quad primitive", 1697)]
- private static void Add3DQuad()
- {
- SceneObject so = UndoRedo.CreateSO("Quad", "Created a quad");
- Renderable renderable = so.AddComponent<Renderable>();
- renderable.Mesh = Builtin.Quad;
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Creates a new scene object with a disc primitive.
- /// </summary>
- [MenuItem("Scene Objects/3D primitives/Disc", 8096)]
- private static void Add3DDisc()
- {
- SceneObject so = UndoRedo.CreateSO("Disc", "Created a disc");
- Renderable renderable = so.AddComponent<Renderable>();
- renderable.Mesh = Builtin.Disc;
- Selection.SceneObject = so;
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Applies changes from the prefab instance to the prefab resource.
- /// </summary>
- [MenuItem("Scene Objects/Apply prefab", 8025, true)]
- private static void ApplyPrefab()
- {
- SceneObject so = Selection.SceneObject;
- if (so == null)
- return;
- PrefabUtility.ApplyPrefab(so);
- }
- /// <summary>
- /// Reverts a prefab instance to the original state of its prefab.
- /// </summary>
- [MenuItem("Scene Objects/Revert to prefab", 8024)]
- private static void RevertToPrefab()
- {
- SceneObject so = Selection.SceneObject;
- if (so == null)
- return;
- UndoRedo.RecordSO(so, true, "Reverting \"" + so.Name + "\" to prefab.");
- PrefabUtility.RevertPrefab(so);
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Breaks a link between a prefab and its instance.
- /// </summary>
- [MenuItem("Scene Objects/Break prefab link", 8023)]
- private static void BreakPrefabLink()
- {
- SceneObject so = Selection.SceneObject;
- if (so == null)
- return;
- UndoRedo.BreakPrefab(so, "Breaking prefab link for " + so.Name);
- EditorApplication.SetSceneDirty();
- }
- /// <summary>
- /// Cuts the currently selected scene object or resource.
- /// </summary>
- [MenuItem("Edit/Cut", 9450, true)]
- public static void Cut()
- {
- if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
- {
- HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
- if (win != null)
- win.CutSelection();
- }
- else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
- {
- LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
- if (win != null)
- win.CutSelection();
- }
- }
- /// <summary>
- /// Copies the currently selected scene object or resource.
- /// </summary>
- [MenuItem("Edit/Copy", 9449)]
- public static void Copy()
- {
- if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
- {
- HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
- if (win != null)
- win.CopySelection();
- }
- else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
- {
- LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
- if (win != null)
- win.CopySelection();
- }
- }
- /// <summary>
- /// Pastes the scene objects or resources that were previously cut or copied.
- /// </summary>
- [MenuItem("Edit/Paste", 9448)]
- public static void Paste()
- {
- // TODO - This is slightly wrong in case both windows have something in their paste buffer (unify them?)
- {
- HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
- if (win != null)
- win.PasteToSelection();
- }
- {
- LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
- if (win != null)
- win.PasteToSelection();
- }
- }
- /// <summary>
- /// Deletes currently selected scene objects or resources.
- /// </summary>
- [MenuItem("Edit/Delete", 9447)]
- public static void Delete()
- {
- if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
- {
- HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
- if (win != null)
- win.DeleteSelection();
- }
- else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
- {
- LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
- if (win != null)
- win.DeleteSelection();
- }
- }
- /// <summary>
- /// Duplicates currently selected scene objects or resources.
- /// </summary>
- [MenuItem("Edit/Duplicate", 9446)]
- public static void Duplicate()
- {
- if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
- {
- HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
- if (win != null)
- win.DuplicateSelection();
- }
- else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
- {
- LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
- if (win != null)
- win.DuplicateSelection();
- }
- }
- }
- }
|