2013-04-17 110 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