summaryrefslogtreecommitdiff
path: root/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs')
-rw-r--r--Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs78
1 files changed, 0 insertions, 78 deletions
diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs
deleted file mode 100644
index 92083794..00000000
--- a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using UnityEngine;
-using UnityEditor;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Reflection;
-
-using UniToolsEditor;
-
-namespace AdvancedInspector
-{
- public class MonoEditor : FieldEditor
- {
- public override bool EditDerived
- {
- get { return false; }
- }
-
- public override Type[] EditedTypes
- {
- get { return new Type[] { typeof(UnityEditor.MonoScript) }; }
- }
-
- public override void Draw(InspectorField field, GUIStyle style)
- {
- if (field.SerializedProperty == null || field.SerializedProperty.serializedObject == null)
- return;
-
- Type type = field.SerializedInstances[0].GetType();
- if (typeof(ComponentMonoBehaviour).IsAssignableFrom(type))
- GUILayout.Label(type.Name);
- else
- {
- EditorGUI.BeginChangeCheck();
-
- field.SerializedProperty.serializedObject.Update();
- EditorGUILayout.PropertyField(field.SerializedProperty, new GUIContent(""));
- field.SerializedProperty.serializedObject.ApplyModifiedProperties();
-
- if (EditorGUI.EndChangeCheck())
- {
- if (field.Parent != null)
- field.Parent.RefreshFields();
- else
- AdvancedInspectorControl.Editor.Instances = new object[] { field.SerializedProperty.serializedObject.targetObject };
- }
- }
-
- DrawObjectSelector(field);
- }
-
- private void DrawObjectSelector(InspectorField field)
- {
- MonoBehaviour behaviour = field.GetValue() as MonoBehaviour;
- if (behaviour == null)
- return;
-
- List<Component> components = new List<Component>(behaviour.gameObject.GetComponents(field.BaseType));
- if (components.Count == 1)
- return;
-
- int index = components.IndexOf(behaviour);
- string[] texts = new string[components.Count];
-
- for (int i = 0; i < components.Count; i++)
- texts[i] = i.ToString() + " : " + components[i].ToString();
-
- EditorGUILayout.BeginHorizontal();
- int selection = EditorGUILayout.Popup(index, texts);
- EditorGUILayout.EndHorizontal();
-
- if (selection == index)
- return;
-
- field.SetValue(components[selection]);
- }
- }
-} \ No newline at end of file