Advertisement
kruncher

ActiveEditorTracker.MakeCustomEditor

Jul 1st, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEditor;
  3.  
  4. public class CustomWindow : EditorWindow {
  5.  
  6.     [MenuItem("Window/Test")]
  7.     public static void Test() {
  8.         EditorWindow.GetWindow<CustomWindow>("Test");
  9.     }
  10.  
  11.     GameObject activeGO;
  12.     Editor editor;
  13.  
  14.     void Update() {
  15.         if (activeGO == Selection.activeGameObject)
  16.             return;
  17.  
  18.         activeGO = Selection.activeGameObject;
  19.         editor = null;
  20.  
  21.         if (activeGO != null)
  22.             editor = UnityEditor.ActiveEditorTracker.MakeCustomEditor(activeGO.transform);
  23.  
  24.         Repaint();
  25.     }
  26.  
  27.     void OnGUI() {
  28.         GameObject go = Selection.activeGameObject;
  29.         if (go == null)
  30.             return;
  31.  
  32.         // Use the registered editor for `Transform`
  33.         EditorGUILayout.InspectorTitlebar(true, editor.target);
  34.         editor.OnInspectorGUI();
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement