浏览代码

[PlanarReflectionProbe] Added preview in scene view

/main
Frédéric Vauchelles 7 年前
当前提交
668f65ae
共有 2 个文件被更改,包括 68 次插入2 次删除
  1. 2
      ScriptableRenderPipeline/Core/CoreRP/Editor/CameraEditorUtils.cs
  2. 68
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs

2
ScriptableRenderPipeline/Core/CoreRP/Editor/CameraEditorUtils.cs


const float k_PreviewNormalizedSize = 0.2f;
internal static Material s_GUITextureBlit2SRGBMaterial;
internal static Material GUITextureBlit2SRGBMaterial
public static Material GUITextureBlit2SRGBMaterial
{
get
{

68
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs


using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine.Experimental.Rendering;
using Object = UnityEngine.Object;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

class PlanarReflectionProbeEditor : Editor
{
static Dictionary<PlanarReflectionProbe, PlanarReflectionProbeUI> s_StateMap = new Dictionary<PlanarReflectionProbe, PlanarReflectionProbeUI>();
const float k_PreviewHeight = 128;
public static bool TryGetUIStateFor(PlanarReflectionProbe p, out PlanarReflectionProbeUI r)
{

{
for (var i = 0; i < m_TypedTargets.Length; i++)
PlanarReflectionProbeUI.DrawHandles(m_UIHandleState[i], m_TypedTargets[i], this);
SceneViewOverlay_Window(_.GetContent("Planar Probe"), OnOverlayGUI, -100, target);
}
void OnOverlayGUI(Object target, SceneView sceneView)
{
var previewSize = new Rect();
for (var i = 0; i < m_TypedTargets.Length; i++)
{
var p = m_TypedTargets[i];
if (p.texture == null)
continue;
var factor = k_PreviewHeight / p.texture.height;
previewSize.x += p.texture.width * factor;
previewSize.y = k_PreviewHeight;
}
// Get and reserve rect
Rect cameraRect = GUILayoutUtility.GetRect(previewSize.x, previewSize.y);
if (Event.current.type == EventType.Repaint)
{
var c = new Rect(cameraRect);
for (var i = 0; i < m_TypedTargets.Length; i++)
{
var p = m_TypedTargets[i];
if (p.texture == null)
continue;
var factor = k_PreviewHeight / p.texture.height;
c.width = p.texture.width * factor;
c.height = k_PreviewHeight;
Graphics.DrawTexture(c, p.texture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, CameraEditorUtils.GUITextureBlit2SRGBMaterial);
c.x += c.width;
}
}
}
public override bool HasPreviewGUI()

else
EditorGUI.LabelField(itemRect, _.GetContent("Not Available"));
}
}
static Type k_SceneViewOverlay_WindowFunction = Type.GetType("UnityEditor.SceneViewOverlay+WindowFunction,UnityEditor");
static Type k_SceneViewOverlay_WindowDisplayOption = Type.GetType("UnityEditor.SceneViewOverlay+WindowDisplayOption,UnityEditor");
static MethodInfo k_SceneViewOverlay_Window = Type.GetType("UnityEditor.SceneViewOverlay,UnityEditor")
.GetMethod(
"Window",
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public,
null,
CallingConventions.Any,
new[] { typeof(GUIContent), k_SceneViewOverlay_WindowFunction, typeof(int), typeof(Object), k_SceneViewOverlay_WindowDisplayOption },
null);
static void SceneViewOverlay_Window(GUIContent title, Action<Object, SceneView> sceneViewFunc, int order, Object target)
{
k_SceneViewOverlay_Window.Invoke(null, new[]
{
title, DelegateUtility.Cast(sceneViewFunc, k_SceneViewOverlay_WindowFunction),
order,
target,
Enum.ToObject(k_SceneViewOverlay_WindowDisplayOption, 1)
});
}
}
}
正在加载...
取消
保存