浏览代码

Merge: missing file

/main
sebastienlagarde 8 年前
当前提交
73c7979a
共有 1 个文件被更改,包括 71 次插入66 次删除
  1. 137
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoopInspector.cs

137
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoopInspector.cs


using UnityEngine;
using System.Collections;
using UnityEngine.Rendering;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
//using EditorGUIUtility=UnityEditor.EditorGUIUtility;

}
private static Styles s_Styles = null;
private static Styles styles { get { if (s_Styles == null) s_Styles = new Styles(); return s_Styles; } }
const float kMaxExposure = 32.0f;
private static Styles styles
{
get
{
if (s_Styles == null)
s_Styles = new Styles();
return s_Styles;
}
}
const float k_MaxExposure = 32.0f;
object[] attributes = type.GetCustomAttributes(true);
var attributes = type.GetCustomAttributes(true);
GenerateHLSL attr = attributes[0] as GenerateHLSL;
var attr = attributes[0] as GenerateHLSL;
if (!attr.needParamDefines)
{

FieldInfo[] fields = type.GetFields();
var fields = type.GetFields();
string subNamespace = type.Namespace.Substring(type.Namespace.LastIndexOf((".")) + 1);
var subNamespace = type.Namespace.Substring(type.Namespace.LastIndexOf((".")) + 1);
int localIndex = 0;
var localIndex = 0;
string name = field.Name;
var fieldName = field.Name;
// Check if the display name have been override by the users
if (Attribute.IsDefined(field, typeof(SurfaceDataAttributes)))
{

name = propertyAttr[0].displayName;
fieldName = propertyAttr[0].displayName;
name = (isBSDFData ? "Engine/" : "") + subNamespace + "/" + name;
fieldName = (isBSDFData ? "Engine/" : "") + subNamespace + "/" + fieldName;
debugViewMaterialStrings[index] = new GUIContent(name);
debugViewMaterialStrings[index] = new GUIContent(fieldName);
debugViewMaterialValues[index] = attr.paramDefinesStart + (int)localIndex;
index++;
localIndex++;

void FillWithPropertiesEnum(Type type, GUIContent[] debugViewMaterialStrings, int[] debugViewMaterialValues, bool isBSDFData, ref int index)
{
String[] names = Enum.GetNames(type);
var names = Enum.GetNames(type);
int localIndex = 0;
var localIndex = 0;
string name = (isBSDFData ? "Engine/" : "") + names[localIndex];
var valueName = (isBSDFData ? "Engine/" : "") + names[localIndex];
debugViewMaterialStrings[index] = new GUIContent(name);
debugViewMaterialStrings[index] = new GUIContent(valueName);
debugViewMaterialValues[index] = (int)value;
index++;
localIndex++;

public override void OnInspectorGUI()
{
HDRenderLoop renderLoop = target as HDRenderLoop;
if (renderLoop)
{
HDRenderLoop.DebugParameters debugParameters = renderLoop.debugParameters;
var renderLoop = target as HDRenderLoop;
EditorGUILayout.LabelField(styles.debugParameters);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
if (!renderLoop)
return;
var debugParameters = renderLoop.debugParameters;
EditorGUILayout.LabelField(styles.debugParameters);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
if (!styles.isDebugViewMaterialInit)
{
String[] varyingNames = Enum.GetNames(typeof(HDRenderLoop.DebugViewVaryingMode));
String[] GBufferNames = Enum.GetNames(typeof(HDRenderLoop.DebugViewGbufferMode));
if (!styles.isDebugViewMaterialInit)
{
var varyingNames = Enum.GetNames(typeof(HDRenderLoop.DebugViewVaryingMode));
var gbufferNames = Enum.GetNames(typeof(HDRenderLoop.DebugViewGbufferMode));
// +1 for the zero case
int num = 1 + varyingNames.Length
+ GBufferNames.Length
+ typeof(Builtin.BuiltinData).GetFields().Length
+ typeof(Lit.SurfaceData).GetFields().Length
+ typeof(Lit.BSDFData).GetFields().Length;
// +1 for the zero case
var num = 1 + varyingNames.Length
+ gbufferNames.Length
+ typeof(Builtin.BuiltinData).GetFields().Length
+ typeof(Lit.SurfaceData).GetFields().Length
+ typeof(Lit.BSDFData).GetFields().Length;
styles.debugViewMaterialStrings = new GUIContent[num];
styles.debugViewMaterialValues = new int[num];
styles.debugViewMaterialStrings = new GUIContent[num];
styles.debugViewMaterialValues = new int[num];
int index = 0;
var index = 0;
// 0 is a reserved number
styles.debugViewMaterialStrings[0] = new GUIContent("None");
styles.debugViewMaterialValues[0] = 0;
index++;
// 0 is a reserved number
styles.debugViewMaterialStrings[0] = new GUIContent("None");
styles.debugViewMaterialValues[0] = 0;
index++;
FillWithPropertiesEnum(typeof(HDRenderLoop.DebugViewVaryingMode), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, ref index);
FillWithProperties(typeof(Builtin.BuiltinData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, ref index);
FillWithProperties(typeof(Lit.SurfaceData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, ref index);
FillWithPropertiesEnum(typeof(HDRenderLoop.DebugViewVaryingMode), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, ref index);
FillWithProperties(typeof(Builtin.BuiltinData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, ref index);
FillWithProperties(typeof(Lit.SurfaceData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, ref index);
// Engine
FillWithPropertiesEnum(typeof(HDRenderLoop.DebugViewGbufferMode), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, true, ref index);
FillWithProperties(typeof(Lit.BSDFData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, true, ref index);
// Engine
FillWithPropertiesEnum(typeof(HDRenderLoop.DebugViewGbufferMode), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, true, ref index);
FillWithProperties(typeof(Lit.BSDFData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, true, ref index);
styles.isDebugViewMaterialInit = true;
}
styles.isDebugViewMaterialInit = true;
}
debugParameters.debugViewMaterial = EditorGUILayout.IntPopup(styles.debugViewMaterial, (int)debugParameters.debugViewMaterial, styles.debugViewMaterialStrings, styles.debugViewMaterialValues);
debugParameters.debugViewMaterial = EditorGUILayout.IntPopup(styles.debugViewMaterial, (int)debugParameters.debugViewMaterial, styles.debugViewMaterialStrings, styles.debugViewMaterialValues);
EditorGUILayout.Space();
debugParameters.enableTonemap = EditorGUILayout.Toggle(styles.enableTonemap, debugParameters.enableTonemap);
debugParameters.exposure = Mathf.Max(Mathf.Min(EditorGUILayout.FloatField(styles.exposure, debugParameters.exposure), kMaxExposure), -kMaxExposure);
EditorGUILayout.Space();
debugParameters.enableTonemap = EditorGUILayout.Toggle(styles.enableTonemap, debugParameters.enableTonemap);
debugParameters.exposure = Mathf.Max(Mathf.Min(EditorGUILayout.FloatField(styles.exposure, debugParameters.exposure), k_MaxExposure), -k_MaxExposure);
EditorGUILayout.Space();
debugParameters.displayOpaqueObjects = EditorGUILayout.Toggle(styles.displayOpaqueObjects, debugParameters.displayOpaqueObjects);
debugParameters.displayTransparentObjects = EditorGUILayout.Toggle(styles.displayTransparentObjects, debugParameters.displayTransparentObjects);
debugParameters.useForwardRenderingOnly = EditorGUILayout.Toggle(styles.useForwardRenderingOnly, debugParameters.useForwardRenderingOnly);
EditorGUILayout.Space();
debugParameters.displayOpaqueObjects = EditorGUILayout.Toggle(styles.displayOpaqueObjects, debugParameters.displayOpaqueObjects);
debugParameters.displayTransparentObjects = EditorGUILayout.Toggle(styles.displayTransparentObjects, debugParameters.displayTransparentObjects);
debugParameters.useForwardRenderingOnly = EditorGUILayout.Toggle(styles.useForwardRenderingOnly, debugParameters.useForwardRenderingOnly);
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(renderLoop); // Repaint
}
EditorGUI.indentLevel--;
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(renderLoop); // Repaint
EditorGUI.indentLevel--;
}
}
}
正在加载...
取消
保存