2013-04-17 112 views

回答

5

您不能强制Unity3D将您的自定义检查器绘制在检查器窗口以外的其他位置。

顺便说一下,您可以使用Editor.CreateEditor方法手动创建Editor。 由于您显示的是自定义检查器,因此应该可以从Window.OnGUI方法内手动实例化它,并使用编辑器的公开OnInspectorGUI方法在窗口中绘制编辑器。

例如,如果你连接一个叫CustomScriptGameObject脚本,并Editor称为CustomScriptEditor,你选择从层次结构中的GameObject假设一个相关的,这个代码可视化定制检查的EditorWindow内:

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();    
     } 

    } 
} 
+0

太棒了!使用startscrollview也能很好地工作! – Klamore74