Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEditor;
- using UnityEditorInternal;
- using UnityEngine;
- internal sealed class Reorder : EditorWindow {
- [MenuItem("Window/Reorder")]
- private static void Init() {
- GetWindow<Reorder>().Show();
- }
- private GameObject selected;
- private Vector2 scroll;
- private void OnGUI() {
- EditorGUILayout.BeginVertical("HelpBox");
- EditorGUILayout.LabelField("Select Gameobject", EditorStyles.boldLabel);
- selected = (GameObject)EditorGUILayout.ObjectField(selected, typeof(GameObject),true);
- EditorGUILayout.Separator();
- EditorGUILayout.EndVertical();
- scroll = EditorGUILayout.BeginScrollView(scroll, false, false);
- if(selected != null)
- for(int i = 0; i < selectionComponents.Length; i++) {
- EditorGUILayout.BeginHorizontal("HelpBox");
- GUI.enabled = i >= 2;
- if(GUILayout.Button("", "OL Plus", GUILayout.Width(15f)))
- ComponentUtility.MoveComponentUp(selectionComponents[i]);
- GUI.enabled = i < selectionComponents.Length - 1 && i >= 1;
- if(GUILayout.Button("", "OL Minus", GUILayout.Width(15f)))
- ComponentUtility.MoveComponentDown(selectionComponents[i]);
- GUI.enabled = true;
- var contend = EditorGUIUtility.ObjectContent(selectionComponents[i], typeof(Component));
- contend.text = selectionComponents[i].GetType().Name;
- EditorGUILayout.LabelField(contend, EditorStyles.boldLabel);
- EditorGUILayout.EndHorizontal();
- }
- EditorGUILayout.EndScrollView();
- }
- private Component[] selectionComponents {
- get {
- return selected.GetComponents<Component>();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement