您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
31 行
1.2 KiB
31 行
1.2 KiB
using System.IO;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
using UnityEngine.Experimental.Rendering;
|
|
using UnityEngine.Experimental.Rendering.HDPipeline;
|
|
|
|
namespace UnityEditor.Experimental.Rendering.HDPipeline
|
|
{
|
|
public class ReflectionMenuItems
|
|
{
|
|
[MenuItem("GameObject/Rendering/Planar Reflection", priority = CoreUtils.gameObjectMenuPriority)]
|
|
static void CreatePlanarReflectionGameObject(MenuCommand menuCommand)
|
|
{
|
|
GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
|
|
GameObjectUtility.SetParentAndAlign(plane, menuCommand.context as GameObject);
|
|
Undo.RegisterCreatedObjectUndo(plane, "Create " + plane.name);
|
|
Selection.activeObject = plane;
|
|
|
|
var planarProbe = plane.AddComponent<PlanarReflectionProbe>();
|
|
planarProbe.influenceVolume.boxBaseSize = new Vector3(10, 0.01f, 10);
|
|
|
|
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
|
|
var material = hdrp != null ? hdrp.GetDefaultMirrorMaterial() : null;
|
|
|
|
if (material)
|
|
{
|
|
plane.GetComponent<MeshRenderer>().sharedMaterial = material;
|
|
}
|
|
}
|
|
}
|
|
}
|