VolumeMenuItems.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using UnityEngine;
  2. using UnityEngine.Rendering;
  3. namespace UnityEditor.Rendering
  4. {
  5. static class VolumeMenuItems
  6. {
  7. const string k_VolumeRootMenu = "GameObject/Volume/";
  8. [MenuItem(k_VolumeRootMenu + "Global Volume", priority = CoreUtils.gameObjectMenuPriority)]
  9. static void CreateGlobalVolume(MenuCommand menuCommand)
  10. {
  11. var go = CoreEditorUtils.CreateGameObject("Global Volume", menuCommand.context);
  12. var volume = go.AddComponent<Volume>();
  13. volume.isGlobal = true;
  14. }
  15. [MenuItem(k_VolumeRootMenu + "Box Volume", priority = CoreUtils.gameObjectMenuPriority)]
  16. static void CreateBoxVolume(MenuCommand menuCommand)
  17. {
  18. var go = CoreEditorUtils.CreateGameObject("Box Volume", menuCommand.context);
  19. var collider = go.AddComponent<BoxCollider>();
  20. collider.isTrigger = true;
  21. var volume = go.AddComponent<Volume>();
  22. volume.isGlobal = false;
  23. volume.blendDistance = 1f;
  24. }
  25. [MenuItem(k_VolumeRootMenu + "Sphere Volume", priority = CoreUtils.gameObjectMenuPriority)]
  26. static void CreateSphereVolume(MenuCommand menuCommand)
  27. {
  28. var go = CoreEditorUtils.CreateGameObject("Sphere Volume", menuCommand.context);
  29. var collider = go.AddComponent<SphereCollider>();
  30. collider.isTrigger = true;
  31. var volume = go.AddComponent<Volume>();
  32. volume.isGlobal = false;
  33. volume.blendDistance = 1f;
  34. }
  35. [MenuItem(k_VolumeRootMenu + "Convex Mesh Volume", priority = CoreUtils.gameObjectMenuPriority)]
  36. static void CreateConvexMeshVolume(MenuCommand menuCommand)
  37. {
  38. var go = CoreEditorUtils.CreateGameObject("Convex Mesh Volume", menuCommand.context);
  39. var collider = go.AddComponent<MeshCollider>();
  40. collider.convex = true;
  41. collider.isTrigger = true;
  42. var volume = go.AddComponent<Volume>();
  43. volume.isGlobal = false;
  44. volume.blendDistance = 1f;
  45. }
  46. }
  47. }