MenuIntegration.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using UnityEngine;
  2. using UnityEditor;
  3. using UnityEditor.SceneManagement;
  4. namespace VolumetricFogAndMist2 {
  5. public class VolumetricFog2EditorIntegration : MonoBehaviour {
  6. [MenuItem("GameObject/Effects/Volumetric Fog 2/Manager", false, 100)]
  7. public static void CreateManager(MenuCommand menuCommand) {
  8. VolumetricFogManager manager = Tools.CheckMainManager();
  9. if (StageUtility.GetCurrentStage() != StageUtility.GetMainStage()) {
  10. StageUtility.PlaceGameObjectInCurrentStage(manager.gameObject);
  11. }
  12. Selection.activeObject = manager.gameObject;
  13. }
  14. [MenuItem("GameObject/Effects/Volumetric Fog 2/Fog Volume", false, 120)]
  15. public static void CreateFogVolume(MenuCommand menuCommand) {
  16. GameObject go = VolumetricFogManager.CreateFogVolume("Volumetric Fog Volume");
  17. GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
  18. if (StageUtility.GetCurrentStage() != StageUtility.GetMainStage()) {
  19. StageUtility.PlaceGameObjectInCurrentStage(go);
  20. }
  21. Undo.RegisterCreatedObjectUndo(go, "Create Fog Volume");
  22. Selection.activeObject = go;
  23. PlaceGameObjectInFrontOfSceneView(go);
  24. }
  25. [MenuItem("GameObject/Effects/Volumetric Fog 2/Fog Void", false, 121)]
  26. public static void CreateFogVoid(MenuCommand menuCommand) {
  27. GameObject go = VolumetricFogManager.CreateFogVoid("Fog Void");
  28. GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
  29. if (StageUtility.GetCurrentStage() != StageUtility.GetMainStage()) {
  30. StageUtility.PlaceGameObjectInCurrentStage(go);
  31. }
  32. go.transform.localScale = new Vector3(30, 10, 30);
  33. Undo.RegisterCreatedObjectUndo(go, "Create Fog Void");
  34. Selection.activeObject = go;
  35. PlaceGameObjectInFrontOfSceneView(go);
  36. }
  37. [MenuItem("GameObject/Effects/Volumetric Fog 2/Fog Sub-Volume", false, 122)]
  38. public static void CreateFogSubVolume(MenuCommand menuCommand) {
  39. GameObject go = VolumetricFogManager.CreateFogSubVolume("Volumetric Fog Sub-Volume");
  40. GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
  41. if (StageUtility.GetCurrentStage() != StageUtility.GetMainStage()) {
  42. StageUtility.PlaceGameObjectInCurrentStage(go);
  43. }
  44. Undo.RegisterCreatedObjectUndo(go, "Create Volumetric Fog Sub-Volume");
  45. Selection.activeObject = go;
  46. PlaceGameObjectInFrontOfSceneView(go);
  47. }
  48. static void PlaceGameObjectInFrontOfSceneView(GameObject go) {
  49. var view = SceneView.lastActiveSceneView;
  50. if (view != null) {
  51. view.MoveToView(go.transform);
  52. }
  53. }
  54. }
  55. }