Frédéric Vauchelles
7 年前
当前提交
8b418188
共有 34 个文件被更改,包括 576 次插入 和 323 次删除
-
100ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/EditorReflectionSystem.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs
-
5ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs
-
32ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeComponentUI.cs.meta
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeEditor.cs.meta
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeUI.cs.meta
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolume.cs.meta
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolumeComponent.cs.meta
-
10ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystem.cs
-
4ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolumeComponent.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs.meta
-
56ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeComponentUI.cs
-
48ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeEditor.cs
-
184ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeUI.cs
-
30ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolume.cs
-
28ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolumeComponent.cs
-
67ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemSceneDictionary.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemSceneDictionary.cs.meta
-
144ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeUI.cs
-
30ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProjectionVolume.cs
-
48ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeComponentUI.cs
-
48ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeEditor.cs
-
28ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProjectionVolumeComponent.cs
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeComponentUI.cs.meta
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeEditor.cs.meta
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeUI.cs.meta
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolume.cs.meta
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolumeComponent.cs.meta
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs.meta
|
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
using CED = CoreEditorDrawer<ProxyVolumeComponentUI, SerializedProxyVolumeComponent>; |
|||
|
|||
class ProxyVolumeComponentUI : BaseUI<SerializedProxyVolumeComponent> |
|||
{ |
|||
public static readonly CED.IDrawer Inspector; |
|||
|
|||
static ProxyVolumeComponentUI() |
|||
{ |
|||
Inspector = CED.Select( |
|||
(s, d, o) => s.proxyVolume, |
|||
(s, d, o) => d.proxyVolume, |
|||
ProxyVolumeUI.SectionShape |
|||
); |
|||
} |
|||
|
|||
public ProxyVolumeUI proxyVolume = new ProxyVolumeUI(); |
|||
|
|||
public ProxyVolumeComponentUI() |
|||
: base(0) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public override void Reset(SerializedProxyVolumeComponent data, UnityAction repaint) |
|||
{ |
|||
proxyVolume.Reset(data.proxyVolume, repaint); |
|||
base.Reset(data, repaint); |
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
proxyVolume.Update(); |
|||
base.Update(); |
|||
} |
|||
|
|||
public static void DrawHandles_EditBase(ProxyVolumeComponentUI ui, ProxyVolumeComponent target) |
|||
{ |
|||
ProxyVolumeUI.DrawHandles_EditBase(target.transform, target.proxyVolume, ui.proxyVolume, target); |
|||
} |
|||
|
|||
public static void DrawHandles_EditNone(ProxyVolumeComponentUI ui, ProxyVolumeComponent target) |
|||
{ |
|||
ProxyVolumeUI.DrawHandles_EditNone(target.transform, target.proxyVolume, ui.proxyVolume, target); |
|||
} |
|||
|
|||
public static void DrawGizmos_EditNone(ProxyVolumeComponentUI ui, ProxyVolumeComponent target) |
|||
{ |
|||
ProxyVolumeUI.DrawGizmos_EditNone(target.transform, target.proxyVolume, ui.proxyVolume, target); |
|||
} |
|||
} |
|||
} |
|
|||
using System.Linq; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[CustomEditor(typeof(ProxyVolumeComponent))] |
|||
[CanEditMultipleObjects] |
|||
class ProxyVolumeEditor : Editor |
|||
{ |
|||
ProxyVolumeComponent[] m_TypedTargets; |
|||
SerializedProxyVolumeComponent m_SerializedData; |
|||
ProxyVolumeComponentUI m_UIState = new ProxyVolumeComponentUI(); |
|||
ProxyVolumeComponentUI[] m_UIHandlerState; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_TypedTargets = targets.Cast<ProxyVolumeComponent>().ToArray(); |
|||
m_SerializedData = new SerializedProxyVolumeComponent(serializedObject); |
|||
|
|||
m_UIState.Reset(m_SerializedData, Repaint); |
|||
|
|||
m_UIHandlerState = new ProxyVolumeComponentUI[m_TypedTargets.Length]; |
|||
for (var i = 0; i < m_UIHandlerState.Length; i++) |
|||
m_UIHandlerState[i] = new ProxyVolumeComponentUI(); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
var s = m_UIState; |
|||
var d = m_SerializedData; |
|||
var o = this; |
|||
|
|||
d.Update(); |
|||
s.Update(); |
|||
|
|||
ProxyVolumeComponentUI.Inspector.Draw(s, d, o); |
|||
|
|||
d.Apply(); |
|||
} |
|||
|
|||
void OnSceneGUI() |
|||
{ |
|||
for (var i = 0; i < m_TypedTargets.Length; i++) |
|||
ProxyVolumeComponentUI.DrawHandles_EditBase(m_UIHandlerState[i], m_TypedTargets[i]); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEditor.IMGUI.Controls; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<ProxyVolumeUI, SerializedProxyVolume>; |
|||
|
|||
class ProxyVolumeUI : BaseUI<SerializedProxyVolume> |
|||
{ |
|||
internal static Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f); |
|||
internal static Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f); |
|||
internal static Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f); |
|||
internal static Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f); |
|||
|
|||
static readonly int k_ShapeCount = Enum.GetValues(typeof(ShapeType)).Length; |
|||
|
|||
public static readonly CED.IDrawer SectionShape; |
|||
|
|||
public static readonly CED.IDrawer SectionShapeBox = CED.Action(Drawer_SectionShapeBox); |
|||
public static readonly CED.IDrawer SectionShapeSphere = CED.Action(Drawer_SectionShapeSphere); |
|||
|
|||
static ProxyVolumeUI() |
|||
{ |
|||
SectionShape = CED.Group( |
|||
CED.Action(Drawer_FieldShapeType), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => s.IsSectionExpanded_Shape((ShapeType)i), |
|||
true, |
|||
SectionShapeBox, |
|||
SectionShapeSphere |
|||
) |
|||
); |
|||
} |
|||
|
|||
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle(); |
|||
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle(); |
|||
|
|||
public ProxyVolumeUI() |
|||
: base(k_ShapeCount) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
base.Update(); |
|||
SetIsSectionExpanded_Shape((ShapeType)data.shapeType.intValue); |
|||
} |
|||
|
|||
void SetIsSectionExpanded_Shape(ShapeType shape) |
|||
{ |
|||
for (var i = 0; i < k_ShapeCount; i++) |
|||
m_AnimBools[i].target = (int)shape == i; |
|||
} |
|||
|
|||
public AnimBool IsSectionExpanded_Shape(ShapeType shapeType) |
|||
{ |
|||
return m_AnimBools[(int)shapeType]; |
|||
} |
|||
|
|||
static void Drawer_FieldShapeType(ProxyVolumeUI s, SerializedProxyVolume d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.shapeType, _.GetContent("Shape Type")); |
|||
} |
|||
|
|||
static void Drawer_SectionShapeBox(ProxyVolumeUI s, SerializedProxyVolume d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.boxSize, _.GetContent("Box Size")); |
|||
EditorGUILayout.PropertyField(d.boxOffset, _.GetContent("Box Offset")); |
|||
EditorGUILayout.PropertyField(d.boxInfiniteProjection, _.GetContent("Infinite Projection")); |
|||
} |
|||
|
|||
static void Drawer_SectionShapeSphere(ProxyVolumeUI s, SerializedProxyVolume d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Sphere Radius")); |
|||
EditorGUILayout.PropertyField(d.sphereOffset, _.GetContent("Sphere Offset")); |
|||
EditorGUILayout.PropertyField(d.sphereInfiniteProjection, _.GetContent("Infinite Projection")); |
|||
} |
|||
|
|||
public static void DrawHandles_EditBase(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset) |
|||
{ |
|||
switch (proxyVolume.shapeType) |
|||
{ |
|||
case ShapeType.Box: |
|||
Handles_EditBase_Box(transform, proxyVolume, ui, sourceAsset); |
|||
break; |
|||
case ShapeType.Sphere: |
|||
Handles_EditBase_Sphere(transform, proxyVolume, ui, sourceAsset); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
public static void DrawHandles_EditNone(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset) |
|||
{ |
|||
|
|||
} |
|||
|
|||
static void Handles_EditBase_Sphere(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI s, Object sourceAsset) |
|||
{ |
|||
s.sphereProjectionHandle.center = proxyVolume.sphereOffset; |
|||
s.sphereProjectionHandle.radius = proxyVolume.sphereRadius; |
|||
|
|||
var mat = Handles.matrix; |
|||
Handles.matrix = transform.localToWorldMatrix; |
|||
Handles.color = k_GizmoThemeColorProjection; |
|||
EditorGUI.BeginChangeCheck(); |
|||
s.sphereProjectionHandle.DrawHandle(); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
Undo.RecordObject(sourceAsset, "Modified Projection Volume"); |
|||
|
|||
proxyVolume.sphereOffset = s.sphereProjectionHandle.center; |
|||
proxyVolume.sphereRadius = s.sphereProjectionHandle.radius; |
|||
|
|||
EditorUtility.SetDirty(sourceAsset); |
|||
} |
|||
Handles.matrix = mat; |
|||
} |
|||
|
|||
static void Handles_EditBase_Box(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI s, Object sourceAsset) |
|||
{ |
|||
s.boxProjectionHandle.center = proxyVolume.boxOffset; |
|||
s.boxProjectionHandle.size = proxyVolume.boxSize; |
|||
|
|||
var mat = Handles.matrix; |
|||
Handles.matrix = transform.localToWorldMatrix; |
|||
|
|||
Handles.color = k_GizmoThemeColorProjection; |
|||
EditorGUI.BeginChangeCheck(); |
|||
s.boxProjectionHandle.DrawHandle(); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
Undo.RecordObject(sourceAsset, "Modified Projection Volume AABB"); |
|||
|
|||
proxyVolume.boxOffset = s.boxProjectionHandle.center; |
|||
proxyVolume.boxSize = s.boxProjectionHandle.size; |
|||
|
|||
EditorUtility.SetDirty(sourceAsset); |
|||
} |
|||
|
|||
Handles.matrix = mat; |
|||
} |
|||
|
|||
public static void DrawGizmos_EditNone(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset) |
|||
{ |
|||
switch (proxyVolume.shapeType) |
|||
{ |
|||
case ShapeType.Box: |
|||
Gizmos_EditNone_Box(transform, proxyVolume, ui, sourceAsset); |
|||
break; |
|||
case ShapeType.Sphere: |
|||
Gizmos_EditNone_Sphere(transform, proxyVolume, ui, sourceAsset); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
static void Gizmos_EditNone_Sphere(Transform t, ProxyVolume d, ProxyVolumeUI s, Object o) |
|||
{ |
|||
var mat = Gizmos.matrix; |
|||
Gizmos.matrix = t.localToWorldMatrix; |
|||
|
|||
Gizmos.color = k_GizmoThemeColorProjection; |
|||
Gizmos.DrawWireSphere(d.sphereOffset, d.sphereRadius); |
|||
|
|||
Gizmos.matrix = mat; |
|||
} |
|||
|
|||
static void Gizmos_EditNone_Box(Transform t, ProxyVolume d, ProxyVolumeUI s, Object o) |
|||
{ |
|||
var mat = Gizmos.matrix; |
|||
Gizmos.matrix = t.localToWorldMatrix; |
|||
|
|||
Gizmos.color = k_GizmoThemeColorProjection; |
|||
Gizmos.DrawWireCube(d.boxOffset, d.boxSize); |
|||
|
|||
Gizmos.matrix = mat; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class SerializedProxyVolume |
|||
{ |
|||
public SerializedProperty root; |
|||
|
|||
public SerializedProperty shapeType; |
|||
public SerializedProperty boxSize; |
|||
public SerializedProperty boxOffset; |
|||
public SerializedProperty boxInfiniteProjection; |
|||
public SerializedProperty sphereRadius; |
|||
public SerializedProperty sphereOffset; |
|||
public SerializedProperty sphereInfiniteProjection; |
|||
|
|||
public SerializedProxyVolume(SerializedProperty root) |
|||
{ |
|||
this.root = root; |
|||
|
|||
shapeType = root.Find((ProxyVolume p) => p.shapeType); |
|||
boxSize = root.Find((ProxyVolume p) => p.boxSize); |
|||
boxOffset = root.Find((ProxyVolume p) => p.boxOffset); |
|||
boxInfiniteProjection = root.Find((ProxyVolume p) => p.boxInfiniteProjection); |
|||
sphereRadius = root.Find((ProxyVolume p) => p.sphereRadius); |
|||
sphereOffset = root.Find((ProxyVolume p) => p.sphereOffset); |
|||
sphereInfiniteProjection = root.Find((ProxyVolume p) => p.sphereInfiniteProjection); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class SerializedProxyVolumeComponent |
|||
{ |
|||
public SerializedObject serializedObject; |
|||
|
|||
public SerializedProxyVolume proxyVolume; |
|||
|
|||
public SerializedProxyVolumeComponent(SerializedObject serializedObject) |
|||
{ |
|||
this.serializedObject = serializedObject; |
|||
|
|||
proxyVolume = new SerializedProxyVolume(serializedObject.Find((ProxyVolumeComponent c) => c.proxyVolume)); |
|||
} |
|||
|
|||
public void Update() |
|||
{ |
|||
serializedObject.Update(); |
|||
} |
|||
|
|||
public void Apply() |
|||
{ |
|||
serializedObject.ApplyModifiedProperties(); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class ReflectionSystemSceneDictionary : MonoBehaviour, ISerializationCallbackReceiver |
|||
{ |
|||
[Serializable] |
|||
class ObjectIDPair |
|||
{ |
|||
public int Key; |
|||
public Object Value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
List<ObjectIDPair> m_ObjectList = new List<ObjectIDPair>(); |
|||
|
|||
Dictionary<Object, int> m_ObjectIndex = new Dictionary<Object, int>(); |
|||
Dictionary<int, Object> m_IDIndex = new Dictionary<int, Object>(); |
|||
|
|||
public int GetIdFor(PlanarReflectionProbe probe) |
|||
{ |
|||
if (m_ObjectIndex.ContainsKey(probe)) |
|||
return m_ObjectIndex[probe]; |
|||
|
|||
var id = FindNextId(); |
|||
m_ObjectList.Add(new ObjectIDPair |
|||
{ |
|||
Key = id, |
|||
Value = probe |
|||
}); |
|||
|
|||
m_ObjectIndex[probe] = id; |
|||
m_IDIndex[id] = probe; |
|||
|
|||
return id; |
|||
} |
|||
|
|||
public void OnBeforeSerialize() |
|||
{ |
|||
for (var i = m_ObjectList.Count - 1; i >= 0; --i) |
|||
{ |
|||
if (m_ObjectList[i].Value == null) |
|||
m_ObjectList.RemoveAt(i); |
|||
} |
|||
} |
|||
|
|||
public void OnAfterDeserialize() |
|||
{ |
|||
for (int i = 0; i < m_ObjectList.Count; i++) |
|||
{ |
|||
if (m_IDIndex.ContainsKey(m_ObjectList[i].Key)) |
|||
Debug.LogErrorFormat(this, "ID {0} is a duplicated in ReflectionSystemSceneDictionary ({1}) for {2}", m_ObjectList[i].Key, this, m_ObjectList[i].Value); |
|||
|
|||
m_ObjectIndex[m_ObjectList[i].Value] = m_ObjectList[i].Key; |
|||
m_IDIndex[m_ObjectList[i].Key] = m_ObjectList[i].Value; |
|||
} |
|||
} |
|||
|
|||
int FindNextId() |
|||
{ |
|||
var id = 0; |
|||
while (m_IDIndex.ContainsKey(id)) ++id; |
|||
return id; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: deb5229fc0604de4cb529aedf764520f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEditor.IMGUI.Controls; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<ProjectionVolumeUI, SerializedProjectionVolume>; |
|||
|
|||
class ProjectionVolumeUI : BaseUI<SerializedProjectionVolume> |
|||
{ |
|||
internal static Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f); |
|||
internal static Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f); |
|||
internal static Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f); |
|||
internal static Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f); |
|||
|
|||
static readonly int k_ShapeCount = Enum.GetValues(typeof(ShapeType)).Length; |
|||
|
|||
public static readonly CED.IDrawer SectionShape; |
|||
|
|||
public static readonly CED.IDrawer SectionShapeBox = CED.Action(Drawer_SectionShapeBox); |
|||
public static readonly CED.IDrawer SectionShapeSphere = CED.Action(Drawer_SectionShapeSphere); |
|||
|
|||
static ProjectionVolumeUI() |
|||
{ |
|||
SectionShape = CED.Group( |
|||
CED.Action(Drawer_FieldShapeType), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => s.IsSectionExpanded_Shape((ShapeType)i), |
|||
true, |
|||
SectionShapeBox, |
|||
SectionShapeSphere |
|||
) |
|||
); |
|||
} |
|||
|
|||
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle(); |
|||
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle(); |
|||
|
|||
public ProjectionVolumeUI() |
|||
: base(k_ShapeCount) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
base.Update(); |
|||
SetIsSectionExpanded_Shape((ShapeType)data.shapeType.intValue); |
|||
} |
|||
|
|||
void SetIsSectionExpanded_Shape(ShapeType shape) |
|||
{ |
|||
for (var i = 0; i < k_ShapeCount; i++) |
|||
m_AnimBools[i].target = (int)shape == i; |
|||
} |
|||
|
|||
public AnimBool IsSectionExpanded_Shape(ShapeType shapeType) |
|||
{ |
|||
return m_AnimBools[(int)shapeType]; |
|||
} |
|||
|
|||
static void Drawer_FieldShapeType(ProjectionVolumeUI s, SerializedProjectionVolume d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.shapeType, _.GetContent("Shape Type")); |
|||
} |
|||
|
|||
static void Drawer_SectionShapeBox(ProjectionVolumeUI s, SerializedProjectionVolume d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.boxSize, _.GetContent("Box Size")); |
|||
EditorGUILayout.PropertyField(d.boxOffset, _.GetContent("Box Offset")); |
|||
EditorGUILayout.PropertyField(d.boxInfiniteProjection, _.GetContent("Infinite Projection")); |
|||
} |
|||
|
|||
static void Drawer_SectionShapeSphere(ProjectionVolumeUI s, SerializedProjectionVolume d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Sphere Radius")); |
|||
EditorGUILayout.PropertyField(d.sphereOffset, _.GetContent("Sphere Offset")); |
|||
EditorGUILayout.PropertyField(d.sphereInfiniteProjection, _.GetContent("Infinite Projection")); |
|||
} |
|||
|
|||
public static void DrawHandles(Transform transform, ProjectionVolume projectionVolume, ProjectionVolumeUI ui, Object sourceAsset) |
|||
{ |
|||
switch (projectionVolume.shapeType) |
|||
{ |
|||
case ShapeType.Box: |
|||
Handles_Box(transform, projectionVolume, ui, sourceAsset); |
|||
break; |
|||
case ShapeType.Sphere: |
|||
Handles_Sphere(transform, projectionVolume, ui, sourceAsset); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
static void Handles_Sphere(Transform transform, ProjectionVolume projectionVolume, ProjectionVolumeUI s, Object sourceAsset) |
|||
{ |
|||
s.sphereProjectionHandle.center = projectionVolume.sphereOffset; |
|||
s.sphereProjectionHandle.radius = projectionVolume.sphereRadius; |
|||
|
|||
var mat = Handles.matrix; |
|||
Handles.matrix = transform.localToWorldMatrix; |
|||
Handles.color = k_GizmoThemeColorProjection; |
|||
EditorGUI.BeginChangeCheck(); |
|||
s.sphereProjectionHandle.DrawHandle(); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
Undo.RecordObject(sourceAsset, "Modified Projection Volume"); |
|||
|
|||
projectionVolume.sphereOffset = s.sphereProjectionHandle.center; |
|||
projectionVolume.sphereRadius = s.sphereProjectionHandle.radius; |
|||
|
|||
EditorUtility.SetDirty(sourceAsset); |
|||
} |
|||
Handles.matrix = mat; |
|||
} |
|||
|
|||
static void Handles_Box(Transform transform, ProjectionVolume projectionVolume, ProjectionVolumeUI s, Object sourceAsset) |
|||
{ |
|||
s.boxProjectionHandle.center = projectionVolume.boxOffset; |
|||
s.boxProjectionHandle.size = projectionVolume.boxSize; |
|||
|
|||
var mat = Handles.matrix; |
|||
Handles.matrix = transform.localToWorldMatrix; |
|||
|
|||
Handles.color = k_GizmoThemeColorProjection; |
|||
EditorGUI.BeginChangeCheck(); |
|||
s.boxProjectionHandle.DrawHandle(); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
Undo.RecordObject(sourceAsset, "Modified Projection Volume AABB"); |
|||
|
|||
projectionVolume.boxOffset = s.boxProjectionHandle.center; |
|||
projectionVolume.boxSize = s.boxProjectionHandle.size; |
|||
|
|||
EditorUtility.SetDirty(sourceAsset); |
|||
} |
|||
|
|||
Handles.matrix = mat; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
class SerializedProjectionVolume |
|||
{ |
|||
public SerializedProperty root; |
|||
|
|||
public SerializedProperty shapeType; |
|||
public SerializedProperty boxSize; |
|||
public SerializedProperty boxOffset; |
|||
public SerializedProperty boxInfiniteProjection; |
|||
public SerializedProperty sphereRadius; |
|||
public SerializedProperty sphereOffset; |
|||
public SerializedProperty sphereInfiniteProjection; |
|||
|
|||
public SerializedProjectionVolume(SerializedProperty root) |
|||
{ |
|||
this.root = root; |
|||
|
|||
shapeType = root.Find((ProjectionVolume p) => p.shapeType); |
|||
boxSize = root.Find((ProjectionVolume p) => p.boxSize); |
|||
boxOffset = root.Find((ProjectionVolume p) => p.boxOffset); |
|||
boxInfiniteProjection = root.Find((ProjectionVolume p) => p.boxInfiniteProjection); |
|||
sphereRadius = root.Find((ProjectionVolume p) => p.sphereRadius); |
|||
sphereOffset = root.Find((ProjectionVolume p) => p.sphereOffset); |
|||
sphereInfiniteProjection = root.Find((ProjectionVolume p) => p.sphereInfiniteProjection); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEditor.Experimental.UIElements; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<ProjectionVolumeComponentUI, SerializedProjectionVolumeComponent>; |
|||
|
|||
class ProjectionVolumeComponentUI : BaseUI<SerializedProjectionVolumeComponent> |
|||
{ |
|||
public static readonly CED.IDrawer Inspector; |
|||
|
|||
static ProjectionVolumeComponentUI() |
|||
{ |
|||
Inspector = CED.Select( |
|||
(s, d, o) => s.projectionVolume, |
|||
(s, d, o) => d.projectionVolume, |
|||
ProjectionVolumeUI.SectionShape |
|||
); |
|||
} |
|||
|
|||
public ProjectionVolumeUI projectionVolume = new ProjectionVolumeUI(); |
|||
|
|||
public ProjectionVolumeComponentUI() |
|||
: base(0) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public override void Reset(SerializedProjectionVolumeComponent data, UnityAction repaint) |
|||
{ |
|||
projectionVolume.Reset(data.projectionVolume, repaint); |
|||
base.Reset(data, repaint); |
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
projectionVolume.Update(); |
|||
base.Update(); |
|||
} |
|||
|
|||
public static void DrawHandles(ProxyVolumeComponent target, ProjectionVolumeComponentUI ui) |
|||
{ |
|||
ProjectionVolumeUI.DrawHandles(target.transform, target.projectionVolume, ui.projectionVolume, target); |
|||
} |
|||
} |
|||
} |
|
|||
using System.Linq; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[CustomEditor(typeof(ProxyVolumeComponent))] |
|||
[CanEditMultipleObjects] |
|||
class ProjectionVolumeEditor : Editor |
|||
{ |
|||
ProxyVolumeComponent[] m_TypedTargets; |
|||
SerializedProjectionVolumeComponent m_SerializedData; |
|||
ProjectionVolumeComponentUI m_UIState = new ProjectionVolumeComponentUI(); |
|||
ProjectionVolumeComponentUI[] m_UIHandlerState; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_TypedTargets = targets.Cast<ProxyVolumeComponent>().ToArray(); |
|||
m_SerializedData = new SerializedProjectionVolumeComponent(serializedObject); |
|||
|
|||
m_UIState.Reset(m_SerializedData, Repaint); |
|||
|
|||
m_UIHandlerState = new ProjectionVolumeComponentUI[m_TypedTargets.Length]; |
|||
for (var i = 0; i < m_UIHandlerState.Length; i++) |
|||
m_UIHandlerState[i] = new ProjectionVolumeComponentUI(); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
var s = m_UIState; |
|||
var d = m_SerializedData; |
|||
var o = this; |
|||
|
|||
d.Update(); |
|||
s.Update(); |
|||
|
|||
ProjectionVolumeComponentUI.Inspector.Draw(s, d, o); |
|||
|
|||
d.Apply(); |
|||
} |
|||
|
|||
void OnSceneGUI() |
|||
{ |
|||
for (var i = 0; i < m_TypedTargets.Length; i++) |
|||
ProjectionVolumeComponentUI.DrawHandles(m_TypedTargets[i], m_UIHandlerState[i]); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
class SerializedProjectionVolumeComponent |
|||
{ |
|||
public SerializedObject serializedObject; |
|||
|
|||
public SerializedProjectionVolume projectionVolume; |
|||
|
|||
public SerializedProjectionVolumeComponent(SerializedObject serializedObject) |
|||
{ |
|||
this.serializedObject = serializedObject; |
|||
|
|||
projectionVolume = new SerializedProjectionVolume(serializedObject.Find((ProxyVolumeComponent c) => c.projectionVolume)); |
|||
} |
|||
|
|||
public void Update() |
|||
{ |
|||
serializedObject.Update(); |
|||
} |
|||
|
|||
public void Apply() |
|||
{ |
|||
serializedObject.ApplyModifiedProperties(); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue