本文介绍了自定义窗口上的Unity自定义检查器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自定义窗口,显示对象列表.每个对象都有一个自定义的检查器编辑器.
I have a custom window that show a list of objects. Each of this objects has a custom inspector editor.
是否可以在自定义窗口中显示自定义检查器?
Is possible to show custom inspector inside the custom window?
推荐答案
您不能强制Unity3D
在检查器窗口之外的其他位置绘制自定义检查器.
You can't force Unity3D
to draw your custom inspector somewhere else than inspector window.
using UnityEditor;
using UnityEngine;
public class TestWindow : EditorWindow
{
[MenuItem ("Window/Editor Window Test")]
static void Init ()
{
// Get existing open window or if none, make a new one:
TestWindow window = (TestWindow)EditorWindow.GetWindow (typeof (TestWindow));
}
void OnGUI () {
GameObject sel = Selection.activeGameObject;
CustomScript targetComp = sel.GetComponent<CustomScript>();
if (targetComp != null)
{
var editor = Editor.CreateEditor(targetComp);
editor.OnInspectorGUI();
}
}
}
这篇关于自定义窗口上的Unity自定义检查器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!