mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
tmp: add debugging for inspector construction
This commit is contained in:
parent
11abeb853b
commit
f01da3fdaa
@ -1,12 +1,14 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEditor.UIElements;
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace nadena.dev.modular_avatar.core.editor
|
namespace nadena.dev.modular_avatar.core.editor
|
||||||
{
|
{
|
||||||
// This class performs common setup for Modular Avatar editors, including ensuring that only one instance of the\
|
// This class performs common setup for Modular Avatar editors, including ensuring that only one instance of the\
|
||||||
// logo is rendered per container.
|
// logo is rendered per container.
|
||||||
public abstract class MAEditorBase : UnityEditor.Editor
|
public abstract class MAEditorBase : Editor
|
||||||
{
|
{
|
||||||
private MAVisualElement _visualElement;
|
private MAVisualElement _visualElement;
|
||||||
private bool _suppressOnceDefaultMargins;
|
private bool _suppressOnceDefaultMargins;
|
||||||
@ -44,12 +46,32 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
if (innerIsImgui)
|
if (innerIsImgui)
|
||||||
{
|
{
|
||||||
var throwaway = new InspectorElement();
|
var throwaway = new InspectorElement();
|
||||||
inner = typeof(InspectorElement).GetMethod("CreateIMGUIInspectorFromEditor",
|
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance)
|
var m_CreateIMGUIInspectorFromEditor = typeof(InspectorElement)
|
||||||
?.Invoke(throwaway, new object[] {serializedObject, this, false}) as VisualElement
|
.GetMethod("CreateIMGUIInspectorFromEditor", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
?? typeof(InspectorElement).GetMethod("CreateInspectorElementUsingIMGUI",
|
var m_CreateInspectorElementUsingIMGUI = typeof(InspectorElement)
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance)
|
.GetMethod("CreateInspectorElementUsingIMGUI", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
?.Invoke(throwaway, new object[] { this }) as VisualElement;
|
|
||||||
|
Debug.Log($"CreateIMGUIInspectorFromEditor found: {m_CreateIMGUIInspectorFromEditor != null}");
|
||||||
|
Debug.Log($"CreateInspectorElementUsingIMGUI found: {m_CreateInspectorElementUsingIMGUI != null}");
|
||||||
|
|
||||||
|
if (m_CreateIMGUIInspectorFromEditor != null)
|
||||||
|
{
|
||||||
|
inner = m_CreateIMGUIInspectorFromEditor.Invoke(throwaway,
|
||||||
|
new object[] { serializedObject, this, false }) as VisualElement;
|
||||||
|
}
|
||||||
|
else if (m_CreateInspectorElementUsingIMGUI != null)
|
||||||
|
{
|
||||||
|
inner = m_CreateInspectorElementUsingIMGUI.Invoke(throwaway,
|
||||||
|
new object[] { this }) as VisualElement;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log(
|
||||||
|
"Neither CreateIMGUIInspectorFromEditor nor CreateInspectorElementUsingIMGUI found, for inspector " +
|
||||||
|
GetType());
|
||||||
|
inner = new VisualElement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_visualElement.Add(inner);
|
_visualElement.Add(inner);
|
||||||
|
Loading…
Reference in New Issue
Block a user