Hello,
I’m trying to extend the ModelImporter inspector, to put a button on top.
The code below work great for the button, but the standard serialization from UnityEditor is lost.
I try to use C# reflection to recover it but it does not work at the time.
How can I do that ?
namespace EditorTools.UVViewer
{
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(ModelImporter))]
public class EditorExtend : Editor
{
private void DisplayModelInspectorGUI()
{
Type type = Type.GetType("UnityEditor.ModelImporterModelEditor,UnityEditor");
if(type != null)
{
MethodInfo info = type.GetMethod("OnInspectorGUI");
if(info != null)
{
object classInstance = Activator.CreateInstance(type, null);
info.Invoke(classInstance, null);
}
}
}
public override void OnInspectorGUI()
{
if (GUILayout.Button("Open UVViewer"))
{
UVViewer window = EditorWindow.GetWindow<UVViewer>();
}
EditorGUILayout.Space();
DisplayModelInspectorGUI();
//DrawDefaultInspector();
}
}
}