GibTreaty

Inspector Component Mover

Feb 14th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. //Put in Assets/Editor
  2.  
  3. using UnityEngine;
  4. using UnityEditor;
  5. using System.Collections;
  6. using UnityEditorInternal;
  7.  
  8. [CustomEditor(typeof(Component), true)]
  9. public class ComponentInspector : Editor {
  10.  
  11.     static GUIContent[] moveComponentToolbar = new GUIContent[] { new GUIContent("á´§", "Move Component Up"), new GUIContent("v", "Move Component Down") };
  12.  
  13.     public override void OnInspectorGUI() {
  14.         GUILayout.BeginHorizontal();
  15.         {
  16.             GUILayout.FlexibleSpace();
  17.             int selected = GUILayout.Toolbar(-1, moveComponentToolbar, GUILayout.ExpandWidth(false));
  18.  
  19.             switch(selected) {
  20.                 case 0: ComponentUtility.MoveComponentUp(target as Component); break;
  21.                 case 1: ComponentUtility.MoveComponentDown(target as Component); break;
  22.             }
  23.         }
  24.         GUILayout.EndHorizontal();
  25.  
  26.         base.OnInspectorGUI();
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment