您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
63 行
2.5 KiB
63 行
2.5 KiB
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
|
|
namespace UnityEditor.Rendering
|
|
{
|
|
public static class VolumeMenuItems
|
|
{
|
|
const string k_VolumeRootMenu = "GameObject/Volume/";
|
|
|
|
static GameObject CreateGameObject(string name, UnityEngine.Object context)
|
|
{
|
|
var parent = context as GameObject;
|
|
var go = CoreEditorUtils.CreateGameObject(parent, name);
|
|
GameObjectUtility.SetParentAndAlign(go, context as GameObject);
|
|
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
|
|
Selection.activeObject = go;
|
|
EditorApplication.ExecuteMenuItem("GameObject/Move To View");
|
|
return go;
|
|
}
|
|
|
|
[MenuItem(k_VolumeRootMenu + "Global Volume", priority = CoreUtils.gameObjectMenuPriority)]
|
|
static void CreateGlobalVolume(MenuCommand menuCommand)
|
|
{
|
|
var go = CreateGameObject("Global Volume", menuCommand.context);
|
|
var volume = go.AddComponent<Volume>();
|
|
volume.isGlobal = true;
|
|
}
|
|
|
|
[MenuItem(k_VolumeRootMenu + "Box Volume", priority = CoreUtils.gameObjectMenuPriority)]
|
|
static void CreateBoxVolume(MenuCommand menuCommand)
|
|
{
|
|
var go = CreateGameObject("Box Volume", menuCommand.context);
|
|
var collider = go.AddComponent<BoxCollider>();
|
|
collider.isTrigger = true;
|
|
var volume = go.AddComponent<Volume>();
|
|
volume.isGlobal = false;
|
|
volume.blendDistance = 1f;
|
|
}
|
|
|
|
[MenuItem(k_VolumeRootMenu + "Sphere Volume", priority = CoreUtils.gameObjectMenuPriority)]
|
|
static void CreateSphereVolume(MenuCommand menuCommand)
|
|
{
|
|
var go = CreateGameObject("Sphere Volume", menuCommand.context);
|
|
var collider = go.AddComponent<SphereCollider>();
|
|
collider.isTrigger = true;
|
|
var volume = go.AddComponent<Volume>();
|
|
volume.isGlobal = false;
|
|
volume.blendDistance = 1f;
|
|
}
|
|
|
|
[MenuItem(k_VolumeRootMenu + "Convex Mesh Volume", priority = CoreUtils.gameObjectMenuPriority)]
|
|
static void CreateConvexMeshVolume(MenuCommand menuCommand)
|
|
{
|
|
var go = CreateGameObject("Convex Mesh Volume", menuCommand.context);
|
|
var collider = go.AddComponent<MeshCollider>();
|
|
collider.convex = true;
|
|
collider.isTrigger = true;
|
|
var volume = go.AddComponent<Volume>();
|
|
volume.isGlobal = false;
|
|
volume.blendDistance = 1f;
|
|
}
|
|
}
|
|
}
|