Update SceneDebugViewerWindow and GlobalShaderProperty.

Compact and normal mode.
More types in global shader property.
Updated global shader property drawer.
SortingOrder for setups.
This commit is contained in:
max 2021-04-20 03:54:55 +02:00
parent 0ce4962c05
commit 42100c5332
14 changed files with 717 additions and 152 deletions

View File

@ -1,6 +1,5 @@
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using System;
namespace TAO.SceneDebugViewer.Editor namespace TAO.SceneDebugViewer.Editor
{ {
@ -31,38 +30,10 @@ namespace TAO.SceneDebugViewer.Editor
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
ReplacementShaderSetupScriptableObject.ParameterType parameterType = (ReplacementShaderSetupScriptableObject.ParameterType)type.enumValueIndex; ReplacementShaderSetupScriptableObject.ParameterType parameterType = (ReplacementShaderSetupScriptableObject.ParameterType)type.enumValueIndex;
SerializedProperty p = null; SerializedProperty p = property.FindPropertyRelative(parameterType.ToString());
bool includeChildren = false;
switch (parameterType) position.height = EditorGUI.GetPropertyHeight(p, includeChildren: true);
{ EditorGUI.PropertyField(position, p, includeChildren: true);
case ReplacementShaderSetupScriptableObject.ParameterType.Texture:
p = property.FindPropertyRelative("m_texture");
break;
case ReplacementShaderSetupScriptableObject.ParameterType.Vector:
p = property.FindPropertyRelative("m_vector");
if (p.isExpanded)
{
position.height = (EditorGUIUtility.singleLineHeight * 4) + (EditorGUIUtility.standardVerticalSpacing * 3);
includeChildren = true;
}
break;
case ReplacementShaderSetupScriptableObject.ParameterType.Color:
p = property.FindPropertyRelative("m_color");
break;
case ReplacementShaderSetupScriptableObject.ParameterType.Float:
p = property.FindPropertyRelative("m_float");
break;
case ReplacementShaderSetupScriptableObject.ParameterType.Int:
p = property.FindPropertyRelative("m_int");
break;
default:
break;
}
EditorGUI.PropertyField(position, p, includeChildren);
} }
EditorGUI.EndProperty(); EditorGUI.EndProperty();
@ -70,37 +41,20 @@ namespace TAO.SceneDebugViewer.Editor
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{ {
int totalLines = 1; var spacing = EditorGUIUtility.standardVerticalSpacing;
var height = EditorGUIUtility.singleLineHeight + spacing;
if (property.isExpanded) if (property.isExpanded)
{ {
totalLines += 3; height += (EditorGUIUtility.singleLineHeight + spacing) * 2;
SerializedProperty type = property.FindPropertyRelative("m_parameterType"); SerializedProperty type = property.FindPropertyRelative("m_parameterType");
ReplacementShaderSetupScriptableObject.ParameterType parameterType = (ReplacementShaderSetupScriptableObject.ParameterType)type.enumValueIndex; ReplacementShaderSetupScriptableObject.ParameterType parameterType = (ReplacementShaderSetupScriptableObject.ParameterType)type.enumValueIndex;
switch (parameterType) height += EditorGUI.GetPropertyHeight(property.FindPropertyRelative(parameterType.ToString()), true);
{
case ReplacementShaderSetupScriptableObject.ParameterType.Texture:
break;
case ReplacementShaderSetupScriptableObject.ParameterType.Vector:
if (property.FindPropertyRelative("m_vector").isExpanded)
{
totalLines += 4;
}
break;
case ReplacementShaderSetupScriptableObject.ParameterType.Color:
break;
case ReplacementShaderSetupScriptableObject.ParameterType.Float:
break;
case ReplacementShaderSetupScriptableObject.ParameterType.Int:
break;
default:
break;
}
} }
return EditorGUIUtility.singleLineHeight * totalLines + EditorGUIUtility.standardVerticalSpacing * (totalLines - 1); return height;
} }
} }
} }

View File

@ -13,9 +13,17 @@ MonoBehaviour:
m_Name: Base m_Name: Base
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
icon: {fileID: 2800000, guid: 1553c43734bfa6345a845ed8637f8fc7, type: 3}
tooltip:
sortingOrder: -99
compact:
m_Text: m_Text:
m_Image: {fileID: 2800000, guid: 1553c43734bfa6345a845ed8637f8fc7, type: 3} m_Image: {fileID: 2800000, guid: 1553c43734bfa6345a845ed8637f8fc7, type: 3}
m_Tooltip: Base Lit m_Tooltip:
normal:
m_Text: ' Base'
m_Image: {fileID: 2800000, guid: 1553c43734bfa6345a845ed8637f8fc7, type: 3}
m_Tooltip:
shader: {fileID: 4800000, guid: fa8b3bbeb520d1c47b2ee619fe14e343, type: 3} shader: {fileID: 4800000, guid: fa8b3bbeb520d1c47b2ee619fe14e343, type: 3}
replacementTag: replacementTag:
parameters: parameters:
@ -23,34 +31,139 @@ MonoBehaviour:
m_parameterType: 0 m_parameterType: 0
m_texture: {fileID: 2800000, guid: f8b8cfeccdb9c194bac037761af51a41, type: 3} m_texture: {fileID: 2800000, guid: f8b8cfeccdb9c194bac037761af51a41, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 0.504, g: 0.504, b: 0.504, a: 1} m_color: {r: 0.504, g: 0.504, b: 0.504, a: 1}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
- m_name: _RS_Sharpness m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Color
m_parameterType: 3 m_parameterType: 3
m_texture: {fileID: 0}
m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 1, b: 1, a: 1}
m_colorArray: []
m_float: 0
m_floatArray: []
m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Sharpness
m_parameterType: 5
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 0, b: 0, a: 0.14901961} m_color: {r: 1, g: 0, b: 0, a: 0.14901961}
m_colorArray: []
m_float: 10 m_float: 10
m_floatArray: []
m_int: 0 m_int: 0
- m_name: _RS_Color m_matrix:
m_parameterType: 2 e00: 0
m_texture: {fileID: 0} e01: 0
m_vector: {x: 0, y: 0, z: 0, w: 0} e02: 0
m_color: {r: 1, g: 1, b: 1, a: 1} e03: 0
m_float: 0 e10: 0
m_int: 0 e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Metallic - m_name: _RS_Metallic
m_parameterType: 3 m_parameterType: 5
m_texture: {fileID: 0} m_texture: {fileID: 0}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 0.504, g: 0.504, b: 0.504, a: 1} m_color: {r: 0.504, g: 0.504, b: 0.504, a: 1}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Glossiness - m_name: _RS_Glossiness
m_parameterType: 3 m_parameterType: 5
m_texture: {fileID: 0} m_texture: {fileID: 0}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 0.504, g: 0.504, b: 0.504, a: 1} m_color: {r: 0.504, g: 0.504, b: 0.504, a: 1}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []

View File

@ -0,0 +1,29 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1aa272ccd1306c545b68254a527f8025, type: 3}
m_Name: Default
m_EditorClassIdentifier:
content:
icon: {fileID: 2800000, guid: 1553c43734bfa6345a845ed8637f8fc7, type: 3}
tooltip:
sortingOrder: -999
compact:
m_Text:
m_Image: {fileID: 2800000, guid: 1553c43734bfa6345a845ed8637f8fc7, type: 3}
m_Tooltip:
normal:
m_Text: ' Default'
m_Image: {fileID: 2800000, guid: 1553c43734bfa6345a845ed8637f8fc7, type: 3}
m_Tooltip:
shader: {fileID: 0}
replacementTag:
parameters: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d76aa8d74b22cea4e9c6355e116cd618
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -13,9 +13,17 @@ MonoBehaviour:
m_Name: GridLit m_Name: GridLit
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
icon: {fileID: 2800000, guid: 1b5be4630aad66c4dbeb577efa26113f, type: 3}
tooltip:
sortingOrder: 10
compact:
m_Text: m_Text:
m_Image: {fileID: 2800000, guid: 1b5be4630aad66c4dbeb577efa26113f, type: 3} m_Image: {fileID: 2800000, guid: 1b5be4630aad66c4dbeb577efa26113f, type: 3}
m_Tooltip: Grid Lit m_Tooltip:
normal:
m_Text: ' GridLit'
m_Image: {fileID: 2800000, guid: 1b5be4630aad66c4dbeb577efa26113f, type: 3}
m_Tooltip:
shader: {fileID: 4800000, guid: 442bea547b43fe643959790eb5b87ede, type: 3} shader: {fileID: 4800000, guid: 442bea547b43fe643959790eb5b87ede, type: 3}
replacementTag: replacementTag:
parameters: parameters:
@ -23,20 +31,83 @@ MonoBehaviour:
m_parameterType: 0 m_parameterType: 0
m_texture: {fileID: 2800000, guid: cb526cf389f85f541aa681de312dd588, type: 3} m_texture: {fileID: 2800000, guid: cb526cf389f85f541aa681de312dd588, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 0, b: 0, a: 0.14901961} m_color: {r: 1, g: 0, b: 0, a: 0.14901961}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
- m_name: _RS_Sharpness m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Color
m_parameterType: 3 m_parameterType: 3
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_color: {r: 1, g: 0, b: 0, a: 0.14901961} m_vectorArray: []
m_color: {r: 1, g: 1, b: 1, a: 1}
m_colorArray: []
m_float: 10 m_float: 10
m_floatArray: []
m_int: 0 m_int: 0
- m_name: _RS_Color m_matrix:
m_parameterType: 2 e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Sharpness
m_parameterType: 5
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_color: {r: 1, g: 1, b: 1, a: 1} m_vectorArray: []
m_color: {r: 1, g: 0, b: 0, a: 0.14901961}
m_colorArray: []
m_float: 10 m_float: 10
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []

View File

@ -13,9 +13,17 @@ MonoBehaviour:
m_Name: GridUnlit m_Name: GridUnlit
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
icon: {fileID: 2800000, guid: 258ec05c639dc22449b3ca11da10d2ae, type: 3}
tooltip:
sortingOrder: 11
compact:
m_Text: m_Text:
m_Image: {fileID: 2800000, guid: 258ec05c639dc22449b3ca11da10d2ae, type: 3} m_Image: {fileID: 2800000, guid: 258ec05c639dc22449b3ca11da10d2ae, type: 3}
m_Tooltip: Grid Unlit m_Tooltip:
normal:
m_Text: ' GridUnlit'
m_Image: {fileID: 2800000, guid: 258ec05c639dc22449b3ca11da10d2ae, type: 3}
m_Tooltip:
shader: {fileID: 4800000, guid: 938a5e8d620c4b943bb6b2b15202678c, type: 3} shader: {fileID: 4800000, guid: 938a5e8d620c4b943bb6b2b15202678c, type: 3}
replacementTag: replacementTag:
parameters: parameters:
@ -23,34 +31,139 @@ MonoBehaviour:
m_parameterType: 0 m_parameterType: 0
m_texture: {fileID: 2800000, guid: cb526cf389f85f541aa681de312dd588, type: 3} m_texture: {fileID: 2800000, guid: cb526cf389f85f541aa681de312dd588, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 0, b: 0, a: 0.14901961} m_color: {r: 1, g: 0, b: 0, a: 0.14901961}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
- m_name: _RS_Sharpness m_matrix:
m_parameterType: 3 e00: 0
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} e01: 0
m_vector: {x: 0, y: 0, z: 0, w: 0} e02: 0
m_color: {r: 1, g: 0, b: 0, a: 0.14901961} e03: 0
m_float: 10 e10: 0
m_int: 0 e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Color - m_name: _RS_Color
m_parameterType: 2 m_parameterType: 3
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 1, b: 1, a: 1} m_color: {r: 1, g: 1, b: 1, a: 1}
m_colorArray: []
m_float: 10 m_float: 10
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Sharpness
m_parameterType: 5
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 0, b: 0, a: 0.14901961}
m_colorArray: []
m_float: 10
m_floatArray: []
m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Metallic - m_name: _RS_Metallic
m_parameterType: 3 m_parameterType: 5
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 1, b: 1, a: 1} m_color: {r: 1, g: 1, b: 1, a: 1}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Glossiness - m_name: _RS_Glossiness
m_parameterType: 3 m_parameterType: 5
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 1, b: 1, a: 1} m_color: {r: 1, g: 1, b: 1, a: 1}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []

View File

@ -13,9 +13,17 @@ MonoBehaviour:
m_Name: ObjectSpaceNormals m_Name: ObjectSpaceNormals
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
icon: {fileID: 2800000, guid: b2efa4ed23d9cd14da026e9eaf25db42, type: 3}
tooltip:
sortingOrder: 20
compact:
m_Text: m_Text:
m_Image: {fileID: 2800000, guid: b2efa4ed23d9cd14da026e9eaf25db42, type: 3} m_Image: {fileID: 2800000, guid: b2efa4ed23d9cd14da026e9eaf25db42, type: 3}
m_Tooltip: Object Space Normals m_Tooltip:
normal:
m_Text: ' ObjectSpaceNormals'
m_Image: {fileID: 2800000, guid: b2efa4ed23d9cd14da026e9eaf25db42, type: 3}
m_Tooltip:
shader: {fileID: 4800000, guid: 7f376fdcb4cabb94fa00a24677019988, type: 3} shader: {fileID: 4800000, guid: 7f376fdcb4cabb94fa00a24677019988, type: 3}
replacementTag: replacementTag:
parameters: [] parameters: []

View File

@ -13,16 +13,45 @@ MonoBehaviour:
m_Name: Overdraw m_Name: Overdraw
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
icon: {fileID: 2800000, guid: 0723191ce0fb9d44ebece6c36fe4776f, type: 3}
tooltip:
sortingOrder: 0
compact:
m_Text: m_Text:
m_Image: {fileID: 2800000, guid: 0723191ce0fb9d44ebece6c36fe4776f, type: 3} m_Image: {fileID: 2800000, guid: 0723191ce0fb9d44ebece6c36fe4776f, type: 3}
m_Tooltip: Overdraw m_Tooltip:
normal:
m_Text: ' Overdraw'
m_Image: {fileID: 2800000, guid: 0723191ce0fb9d44ebece6c36fe4776f, type: 3}
m_Tooltip:
shader: {fileID: 4800000, guid: 9f96928510529524c9190ccf618ceaf8, type: 3} shader: {fileID: 4800000, guid: 9f96928510529524c9190ccf618ceaf8, type: 3}
replacementTag: replacementTag:
parameters: parameters:
- m_name: _RS_Color - m_name: _RS_Color
m_parameterType: 2 m_parameterType: 3
m_texture: {fileID: 0} m_texture: {fileID: 0}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 0, b: 0, a: 0.101960786} m_color: {r: 1, g: 0, b: 0, a: 0.101960786}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []

View File

@ -13,9 +13,17 @@ MonoBehaviour:
m_Name: UVChecker m_Name: UVChecker
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
icon: {fileID: 2800000, guid: d41389bd7fb002d48a1bb9b0fd1b4cf1, type: 3}
tooltip:
sortingOrder: 35
compact:
m_Text: m_Text:
m_Image: {fileID: 2800000, guid: d41389bd7fb002d48a1bb9b0fd1b4cf1, type: 3} m_Image: {fileID: 2800000, guid: d41389bd7fb002d48a1bb9b0fd1b4cf1, type: 3}
m_Tooltip: UV Checker m_Tooltip:
normal:
m_Text: ' UVChecker'
m_Image: {fileID: 2800000, guid: d41389bd7fb002d48a1bb9b0fd1b4cf1, type: 3}
m_Tooltip:
shader: {fileID: 4800000, guid: b7f90ee778e287d4f9bde3252fe9bdd9, type: 3} shader: {fileID: 4800000, guid: b7f90ee778e287d4f9bde3252fe9bdd9, type: 3}
replacementTag: replacementTag:
parameters: parameters:
@ -23,34 +31,139 @@ MonoBehaviour:
m_parameterType: 0 m_parameterType: 0
m_texture: {fileID: 2800000, guid: f2e2a666b464cc84982b530d4dcd36d7, type: 3} m_texture: {fileID: 2800000, guid: f2e2a666b464cc84982b530d4dcd36d7, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 0, b: 0, a: 0.14901961} m_color: {r: 1, g: 0, b: 0, a: 0.14901961}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
- m_name: _RS_Sharpness m_matrix:
m_parameterType: 3 e00: 0
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} e01: 0
m_vector: {x: 0, y: 0, z: 0, w: 0} e02: 0
m_color: {r: 1, g: 0, b: 0, a: 0.14901961} e03: 0
m_float: 10 e10: 0
m_int: 0 e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Color - m_name: _RS_Color
m_parameterType: 2 m_parameterType: 3
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 1, b: 1, a: 1} m_color: {r: 1, g: 1, b: 1, a: 1}
m_colorArray: []
m_float: 10 m_float: 10
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Sharpness
m_parameterType: 5
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 0, b: 0, a: 0.14901961}
m_colorArray: []
m_float: 10
m_floatArray: []
m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Metallic - m_name: _RS_Metallic
m_parameterType: 3 m_parameterType: 5
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 1, b: 1, a: 1} m_color: {r: 1, g: 1, b: 1, a: 1}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []
- m_name: _RS_Glossiness - m_name: _RS_Glossiness
m_parameterType: 3 m_parameterType: 5
m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3} m_texture: {fileID: 2800000, guid: 60a6c65bf59247d41bcc18553d97d2c5, type: 3}
m_vector: {x: 0, y: 0, z: 0, w: 0} m_vector: {x: 0, y: 0, z: 0, w: 0}
m_vectorArray: []
m_color: {r: 1, g: 1, b: 1, a: 1} m_color: {r: 1, g: 1, b: 1, a: 1}
m_colorArray: []
m_float: 0 m_float: 0
m_floatArray: []
m_int: 0 m_int: 0
m_matrix:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
m_matrixArray: []

View File

@ -13,9 +13,17 @@ MonoBehaviour:
m_Name: VertexColors m_Name: VertexColors
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
icon: {fileID: 2800000, guid: c7374f0b36a3eb4409b17770bf46b076, type: 3}
tooltip:
sortingOrder: 0
compact:
m_Text: m_Text:
m_Image: {fileID: 2800000, guid: c7374f0b36a3eb4409b17770bf46b076, type: 3} m_Image: {fileID: 2800000, guid: c7374f0b36a3eb4409b17770bf46b076, type: 3}
m_Tooltip: Vertex Colors m_Tooltip:
normal:
m_Text: ' VertexColors'
m_Image: {fileID: 2800000, guid: c7374f0b36a3eb4409b17770bf46b076, type: 3}
m_Tooltip:
shader: {fileID: 4800000, guid: 0a3c678aaad08094ebfd936fda70bb21, type: 3} shader: {fileID: 4800000, guid: 0a3c678aaad08094ebfd936fda70bb21, type: 3}
replacementTag: replacementTag:
parameters: [] parameters: []

View File

@ -13,9 +13,17 @@ MonoBehaviour:
m_Name: WorldSpaceNormals m_Name: WorldSpaceNormals
m_EditorClassIdentifier: m_EditorClassIdentifier:
content: content:
icon: {fileID: 2800000, guid: d9b83aa61ceb006419b0c2460bbbe3cc, type: 3}
tooltip:
sortingOrder: 21
compact:
m_Text: m_Text:
m_Image: {fileID: 2800000, guid: d9b83aa61ceb006419b0c2460bbbe3cc, type: 3} m_Image: {fileID: 2800000, guid: d9b83aa61ceb006419b0c2460bbbe3cc, type: 3}
m_Tooltip: World Space Normals m_Tooltip:
normal:
m_Text: ' WorldSpaceNormals'
m_Image: {fileID: 2800000, guid: d9b83aa61ceb006419b0c2460bbbe3cc, type: 3}
m_Tooltip:
shader: {fileID: 4800000, guid: f2163d0d9cb9f8a4fbb6c07dcf8ac7d3, type: 3} shader: {fileID: 4800000, guid: f2163d0d9cb9f8a4fbb6c07dcf8ac7d3, type: 3}
replacementTag: replacementTag:
parameters: [] parameters: []

View File

@ -9,13 +9,16 @@ namespace TAO.SceneDebugViewer.Editor
public class ReplacementShaderSetupScriptableObject : ScriptableObject public class ReplacementShaderSetupScriptableObject : ScriptableObject
{ {
[Header("GUI")] [Header("GUI")]
public GUIContent content = new GUIContent(); [SerializeField]
private GContent content = new GContent();
public GContent Content => content;
[Header("Shader")] [Header("Shader")]
public Shader shader = null; public Shader shader = null;
public string replacementTag = ""; public string replacementTag = "";
public List<GlobalShaderParameter> parameters = new List<GlobalShaderParameter>(); public List<GlobalShaderParameter> parameters = new List<GlobalShaderParameter>();
public void Replace() public virtual void Replace()
{ {
SetupShaderParameters(); SetupShaderParameters();
@ -34,6 +37,16 @@ namespace TAO.SceneDebugViewer.Editor
} }
} }
private void OnValidate()
{
content.compact.text = null;
content.compact.image = content.icon;
content.compact.tooltip = content.tooltip;
content.normal.text = string.Format(" {0}", name);
content.normal.image = content.icon;
content.normal.tooltip = content.tooltip;
}
[System.Serializable] [System.Serializable]
public struct GlobalShaderParameter public struct GlobalShaderParameter
{ {
@ -43,29 +56,49 @@ namespace TAO.SceneDebugViewer.Editor
public Texture2D m_texture; public Texture2D m_texture;
public Vector4 m_vector; public Vector4 m_vector;
public Vector4[] m_vectorArray;
public Color m_color; public Color m_color;
public Color[] m_colorArray;
public float m_float; public float m_float;
public float[] m_floatArray;
public int m_int; public int m_int;
public Matrix4x4 m_matrix;
public Matrix4x4[] m_matrixArray;
public void Set() public void Set()
{ {
switch (m_parameterType) switch (m_parameterType)
{ {
case ParameterType.Texture: case ParameterType.m_texture:
Shader.SetGlobalTexture(m_name, m_texture); Shader.SetGlobalTexture(m_name, m_texture);
break; break;
case ParameterType.Vector: case ParameterType.m_vector:
Shader.SetGlobalVector(m_name, m_vector); Shader.SetGlobalVector(m_name, m_vector);
break; break;
case ParameterType.Color: case ParameterType.m_vectorArray:
Shader.SetGlobalVectorArray(m_name, m_vectorArray);
break;
case ParameterType.m_color:
Shader.SetGlobalColor(m_name, m_color); Shader.SetGlobalColor(m_name, m_color);
break; break;
case ParameterType.Float: case ParameterType.m_colorArray:
Shader.SetGlobalVectorArray(m_name, ColorArrayToVector4Array(m_colorArray));
break;
case ParameterType.m_float:
Shader.SetGlobalFloat(m_name, m_float); Shader.SetGlobalFloat(m_name, m_float);
break; break;
case ParameterType.Int: case ParameterType.m_floatArray:
Shader.SetGlobalFloatArray(m_name, m_floatArray);
break;
case ParameterType.m_int:
Shader.SetGlobalInt(m_name, m_int); Shader.SetGlobalInt(m_name, m_int);
break; break;
case ParameterType.m_matrix:
Shader.SetGlobalMatrix(m_name, m_matrix);
break;
case ParameterType.m_matrixArray:
Shader.SetGlobalMatrixArray(m_name, m_matrixArray);
break;
default: default:
break; break;
} }
@ -74,11 +107,54 @@ namespace TAO.SceneDebugViewer.Editor
public enum ParameterType public enum ParameterType
{ {
Texture, m_texture,
Vector, m_vector,
Color, m_vectorArray,
Float, m_color,
Int m_colorArray,
m_float,
m_floatArray,
m_int,
m_matrix,
m_matrixArray
}
private static Vector4[] ColorArrayToVector4Array(Color[] c)
{
Vector4[] v = new Vector4[c.Length];
for (int i = 0; i < v.Length; i++)
{
v[i] = c[i];
}
return v;
}
[System.Serializable]
public struct GContent
{
public Texture2D icon;
public string tooltip;
public int sortingOrder;
[HideInInspector]
public GUIContent compact;
[HideInInspector]
public GUIContent normal;
}
}
public class RSSOComparer : IComparer<ReplacementShaderSetupScriptableObject>
{
public int Compare(ReplacementShaderSetupScriptableObject x, ReplacementShaderSetupScriptableObject y)
{
if (x == null || y == null)
{
return 0;
}
return x.Content.sortingOrder.CompareTo(y.Content.sortingOrder);
} }
} }
#endif #endif

View File

@ -6,8 +6,10 @@ namespace TAO.SceneDebugViewer.Editor
{ {
public class SceneDebugViewerWindow : EditorWindow public class SceneDebugViewerWindow : EditorWindow
{ {
private static SceneDebugViewerWindow window = null; public static SceneDebugViewerWindow window = null;
private static List<ReplacementShaderSetupScriptableObject> options = new List<ReplacementShaderSetupScriptableObject>(); public static List<ReplacementShaderSetupScriptableObject> options = new List<ReplacementShaderSetupScriptableObject>();
private GUIStyle optionsButtonStyle = null;
[MenuItem("Window/Analysis/SceneDebugViewer")] [MenuItem("Window/Analysis/SceneDebugViewer")]
static void Init() static void Init()
@ -16,13 +18,18 @@ namespace TAO.SceneDebugViewer.Editor
window = (SceneDebugViewerWindow)GetWindow(typeof(SceneDebugViewerWindow)); window = (SceneDebugViewerWindow)GetWindow(typeof(SceneDebugViewerWindow));
window.titleContent = new GUIContent("SDV"); window.titleContent = new GUIContent("SDV");
window.maxSize = new Vector2(101, window.maxSize.y); //window.maxSize = new Vector2(101, window.maxSize.y);
window.minSize = new Vector2(101, window.minSize.y); window.minSize = new Vector2(101, window.minSize.y);
window.Show(); window.Show();
} }
private void OnGUI() private void OnGUI()
{ {
if (window == null)
{
window = (SceneDebugViewerWindow)GetWindow(typeof(SceneDebugViewerWindow));
}
using (new GUILayout.VerticalScope()) using (new GUILayout.VerticalScope())
{ {
if (GUILayout.Button("Reload")) if (GUILayout.Button("Reload"))
@ -30,31 +37,27 @@ namespace TAO.SceneDebugViewer.Editor
Load(); Load();
} }
GUILayout.Space(6); if (window.position.width <= 101)
if (GUILayout.Button("Default", GUILayout.Height(44)))
{ {
foreach (SceneView s in SceneView.sceneViews) // Compact grid.
optionsButtonStyle = new GUIStyle(GUI.skin.button)
{ {
s.SetSceneViewShaderReplace(null, null); alignment = TextAnchor.MiddleCenter,
s.Repaint(); fixedHeight = 44
} };
}
GUILayout.Space(6);
for (int i = 0; i < options.Count; i += 2) for (int i = 0; i < options.Count; i += 2)
{ {
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
if (GUILayout.Button(options[i].content, GUILayout.Height(44))) if (GUILayout.Button(options[i].Content.compact, optionsButtonStyle))
{ {
options[i].Replace(); options[i].Replace();
} }
if (i + 1 < options.Count) if (i + 1 < options.Count)
{ {
if (GUILayout.Button(options[i + 1].content, GUILayout.Height(44))) if (GUILayout.Button(options[i + 1].Content.compact, optionsButtonStyle))
{ {
options[i + 1].Replace(); options[i + 1].Replace();
} }
@ -63,18 +66,48 @@ namespace TAO.SceneDebugViewer.Editor
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
} }
} }
else
{
// Normal list.
optionsButtonStyle = new GUIStyle(GUI.skin.button)
{
alignment = TextAnchor.MiddleLeft,
fixedHeight = 44
};
for (int i = 0; i < options.Count; i ++)
{
if (GUILayout.Button(options[i].Content.normal, optionsButtonStyle))
{
options[i].Replace();
}
}
}
}
} }
private static void Load() private static void Load()
{ {
options.Clear(); options.Clear();
string[] guids = AssetDatabase.FindAssets("t:ReplacementShaderSetupScriptableObject", null); string[] guids = AssetDatabase.FindAssets(string.Format("t:{0}", typeof(ReplacementShaderSetupScriptableObject).ToString()), null);
foreach (string guid in guids) foreach (string guid in guids)
{ {
options.Add((ReplacementShaderSetupScriptableObject)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(ReplacementShaderSetupScriptableObject))); options.Add((ReplacementShaderSetupScriptableObject)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(ReplacementShaderSetupScriptableObject)));
} }
SortOptions();
}
private static void SortOptions()
{
if (options != null)
{
RSSOComparer comparer = new RSSOComparer();
options.Sort(comparer);
}
} }
} }
} }

View File

@ -3,7 +3,9 @@ guid: af04cbc3f49c9e84dbab665498c4f129
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences:
- m_ViewDataDictionary: {instanceID: 0}
- skin: {fileID: 11400000, guid: 704ab495088bed748a18e35633bf42a0, type: 2}
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData: