2013-04-17 8 views

答えて

5

Unity3Dでは、インスペクタウインドウ以外にカスタムインスペクタを描画することはできません。

Btw Editor.CreateEditorメソッドを使用して手動でEditorを導入することができます。 カスタムインスペクタを表示しているので、Window.OnGUIメソッドから手動でインスタンスをインスタンス化し、エディタのpublic OnInspectorGUIメソッドを使用してウィンドウ内にエディタを描画する必要があります。

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

    } 
} 
:あなたは GameObjectCustomScriptというスクリプトを添付しており、関連 Editorはあなたが階層から GameObjectを選択していると仮定、 CustomScriptEditorと呼ばれている、このコードは EditorWindow内のカスタムインスペクタを可視化する場合たとえば

+0

素晴らしい! begincrollviewでもうまく動作します! – Klamore74

関連する問題