Julien Ignace
8 年前
当前提交
54b035df
共有 6 个文件被更改,包括 125 次插入 和 41 次删除
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs
-
17Assets/ScriptableRenderPipeline/common/Debugging/DebugMenu.cs
-
4Assets/ScriptableRenderPipeline/common/Debugging/DebugMenuManager.cs
-
34Assets/ScriptableRenderPipeline/common/Debugging/Editor/DebugMenuEditor.cs
-
97Assets/ScriptableRenderPipeline/common/Debugging/DebugItemDrawer.cs
-
12Assets/ScriptableRenderPipeline/common/Debugging/DebugItemDrawer.cs.meta
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using System; |
|||
|
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
|
|||
namespace UnityEngine.Experimental.Rendering |
|||
{ |
|||
public class DebugItemDrawer |
|||
{ |
|||
protected DebugMenuItem m_MenuItem = null; |
|||
|
|||
public DebugItemDrawer() |
|||
{ |
|||
} |
|||
|
|||
public void SetDebugItem(DebugMenuItem item) |
|||
{ |
|||
m_MenuItem = item; |
|||
} |
|||
|
|||
public virtual void ClampValues(Func<object> getter, Action<object> setter) {} |
|||
public virtual void BuildGUI() {} |
|||
|
|||
#if UNITY_EDITOR
|
|||
void DrawBoolItem() |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
bool value = EditorGUILayout.Toggle(m_MenuItem.name, (bool)m_MenuItem.GetValue()); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
m_MenuItem.SetValue(value); |
|||
} |
|||
} |
|||
|
|||
void DrawFloatItem() |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
float value = EditorGUILayout.FloatField(m_MenuItem.name, (float)m_MenuItem.GetValue()); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
m_MenuItem.SetValue(value); |
|||
} |
|||
} |
|||
|
|||
public virtual void OnEditorGUI() |
|||
{ |
|||
if (m_MenuItem.GetItemType() == typeof(bool)) |
|||
{ |
|||
DrawBoolItem(); |
|||
} |
|||
else if (m_MenuItem.GetItemType() == typeof(float)) |
|||
{ |
|||
DrawFloatItem(); |
|||
} |
|||
} |
|||
#endif
|
|||
} |
|||
|
|||
public class DebugItemDrawFloatMinMax |
|||
: DebugItemDrawer |
|||
{ |
|||
float m_Min = 0.0f; |
|||
float m_Max = 1.0f; |
|||
public DebugItemDrawFloatMinMax(float min, float max) |
|||
{ |
|||
m_Min = min; |
|||
m_Max = max; |
|||
} |
|||
|
|||
public override void ClampValues(Func<object> getter, Action<object> setter) |
|||
{ |
|||
if (m_MenuItem == null) |
|||
return; |
|||
|
|||
if(m_MenuItem.GetItemType() == typeof(float)) |
|||
{ |
|||
setter(Mathf.Clamp((float)getter(), m_Min, m_Max)); |
|||
} |
|||
} |
|||
|
|||
#if UNITY_EDITOR
|
|||
public override void OnEditorGUI() |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
float value = EditorGUILayout.Slider(m_MenuItem.name, (float)m_MenuItem.GetValue(), m_Min, m_Max); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
m_MenuItem.SetValue(value); |
|||
} |
|||
} |
|||
#endif
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7e413732cbed94f4688d5c59709a4556 |
|||
timeCreated: 1492787007 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue