UniVRM/Assets/VRM10/Editor/Components/SpringBone/CustomInspector.cs
ousttrue d53942a7bd merge vrm10
* MeshUtility を UniGLTF 下に移動
* Assets/VRM10 を追加
* JsonSchemaからのコード生成 UniGLTF/Editor/Generator を追加
2021-01-07 13:37:24 +09:00

60 lines
1.6 KiB
C#

using System;
using UnityEditor;
using UnityEngine;
namespace UniVRM10
{
struct CustomInspector : IDisposable
{
SerializedObject serializedObject;
int m_depth;
Func<SerializedProperty, bool> m_callback;
public CustomInspector(SerializedObject so, int depth = 0, Func<SerializedProperty, bool> callback = null)
{
m_depth = depth;
m_callback = callback;
serializedObject = so;
serializedObject.Update();
}
public void OnInspectorGUI()
{
int currentDepth = 0;
for (var iterator = serializedObject.GetIterator(); iterator.NextVisible(true);)
{
var isCollapsed = currentDepth < iterator.depth;
if (isCollapsed)
{
continue;
}
#if DEBUG
// Debug.Log($"{iterator.propertyPath}({iterator.propertyType})");
#endif
if (m_callback is null || !m_callback(iterator))
{
EditorGUI.indentLevel = iterator.depth + m_depth;
EditorGUILayout.PropertyField(iterator, false);
}
if (iterator.isExpanded)
{
currentDepth = iterator.depth + 1;
}
else
{
currentDepth = iterator.depth;
}
}
}
public void Dispose()
{
serializedObject.ApplyModifiedProperties();
}
}
}