diff options
Diffstat (limited to 'Assets/Plugins')
243 files changed, 12116 insertions, 0 deletions
diff --git a/Assets/Plugins/AdvancedInspector.meta b/Assets/Plugins/AdvancedInspector.meta new file mode 100644 index 00000000..88e09945 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: e2988672ababca043abe1b5c8852c4ec +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes.meta b/Assets/Plugins/AdvancedInspector/Attributes.meta new file mode 100644 index 00000000..37a6962f --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: f415bc03d4b29594193286c0bef51f76 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/AdvancedInspector.cs b/Assets/Plugins/AdvancedInspector/Attributes/AdvancedInspector.cs new file mode 100644 index 00000000..047710d5 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/AdvancedInspector.cs @@ -0,0 +1,60 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Turn off the default Inspector in favor or the Advanced one. + /// If false, both may be draw if some members are flagged "Inspect", one after the other... + /// </summary> + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = true)] + public class AdvancedInspectorAttribute : Attribute + { + private bool inspectDefaultItems = false; + + /// <summary> + /// If true, the Advanced Inspector inspect all the item the default Inspector does without adding the [Inspect] attribute. + /// You can still add item that Unity would not display by adding the [Inspect] attribute. + /// </summary> + public bool InspectDefaultItems + { + get { return inspectDefaultItems; } + set { inspectDefaultItems = value; } + } + + private bool showScript = true; + + /// <summary> + /// Show or hide the script field at the top of the inspector. + /// The script field allow to change the type of the object. + /// </summary> + public bool ShowScript + { + get { return showScript; } + set { showScript = value; } + } + + private bool expandable = true; + + /// <summary> + /// Is this object expandable in a in-lined context? + /// </summary> + public bool Expandable + { + get { return expandable; } + set { expandable = value; } + } + + public AdvancedInspectorAttribute() { } + + public AdvancedInspectorAttribute(bool inspectDefaultItems) + { + this.inspectDefaultItems = inspectDefaultItems; + } + + public AdvancedInspectorAttribute(bool inspectDefaultItems, bool showScript) + { + this.showScript = showScript; + this.inspectDefaultItems = inspectDefaultItems; + } + } +} diff --git a/Assets/Plugins/AdvancedInspector/Attributes/AdvancedInspector.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/AdvancedInspector.cs.meta new file mode 100644 index 00000000..c0c82e2e --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/AdvancedInspector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 37170739434a8a74bb0aae3f57b1ed64 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Angle.cs b/Assets/Plugins/AdvancedInspector/Attributes/Angle.cs new file mode 100644 index 00000000..8b80ade5 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Angle.cs @@ -0,0 +1,34 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Turns a float/int into a spinning knob. + /// Because... Fancy. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class AngleAttribute : Attribute, IListAttribute + { + private float snap = -1; + + /// <summary> + /// Makes the control snap to the multiple of that value + /// Default; -1. Negative values turn this behaviour off. + /// </summary> + public float Snap + { + get { return snap; } + } + + public AngleAttribute() { } + + /// <summary> + /// If snap is -1, the snap is disable. + /// Snap makes the wheel "stick" to multiple of a fixed value. + /// </summary> + public AngleAttribute(float snap) + { + this.snap = snap; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Angle.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Angle.cs.meta new file mode 100644 index 00000000..1afd5dc4 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Angle.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce761f6d5740bc9438033f37b24d3923 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Background.cs b/Assets/Plugins/AdvancedInspector/Attributes/Background.cs new file mode 100644 index 00000000..e5ade555 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Background.cs @@ -0,0 +1,100 @@ +using System; +using UnityEngine; +using System.Reflection; +using System.Collections.Generic; + +namespace AdvancedInspector +{ + /// <summary> + /// Changes the color of the background of an expandable item. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct)] + public class BackgroundAttribute : Attribute, IRuntimeAttribute<Color> + { + public delegate Color BackgroundDelegate(); + public delegate Color BackgroundStaticDelegate(BackgroundAttribute background, object instance, object value); + + private Color color = Color.clear; + + /// <summary> + /// Give this item's background a color. + /// </summary> + public Color Color + { + get { return color; } + set { color = value; } + } + + #region IRuntime Implementation + private string methodName = ""; + + public string MethodName + { + get { return methodName; } + set { methodName = value; } + } + + public Type Template + { + get { return typeof(BackgroundDelegate); } + } + + public Type TemplateStatic + { + get { return typeof(BackgroundStaticDelegate); } + } + + private List<Delegate> delegates = new List<Delegate>(); + + public List<Delegate> Delegates + { + get { return delegates; } + set { delegates = value; } + } + + public Color Invoke(int index, object instance, object value) + { + if (delegates.Count == 0 || index >= delegates.Count) + return color; + + try + { + if (delegates[index].Target == null) + { + return (Color)delegates[index].DynamicInvoke(this, instance, value); + } + else + { + return (Color)delegates[index].DynamicInvoke(); + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + e = ((TargetInvocationException)e).InnerException; + + Debug.LogError(string.Format("Invoking a method to retrieve a Background attribute failed. The exception was \"{0}\".", e.Message)); + return color; + } + } + #endregion + + public BackgroundAttribute(string methodName) + { + this.methodName = methodName; + } + + public BackgroundAttribute(Delegate method) + { + this.delegates.Add(method); + } + + public BackgroundAttribute(float r, float g, float b) + : this(r, g, b, 1) { } + + public BackgroundAttribute(float r, float g, float b, float a) + { + this.color = new Color(r, g, b, a); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Background.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Background.cs.meta new file mode 100644 index 00000000..71c26ea6 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Background.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4b99ed308d9ecd94eac01d3045a59165 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Bypass.cs b/Assets/Plugins/AdvancedInspector/Attributes/Bypass.cs new file mode 100644 index 00000000..3419ebb6 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Bypass.cs @@ -0,0 +1,13 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Since internal Unity classes are not "Advanced Inspector" friendly, + /// this attribute force their own members to be exposed without the need of "InspectAttribute". + /// Be careful, all public property/fields will be exposed in a recursive manner. + /// This may expose stuff that were not meant to be exposed. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class BypassAttribute : Attribute, IListAttribute { } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Bypass.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Bypass.cs.meta new file mode 100644 index 00000000..fb65f729 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Bypass.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eae36bd4c4e7de04d920900da8944a23 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Collection.cs b/Assets/Plugins/AdvancedInspector/Attributes/Collection.cs new file mode 100644 index 00000000..2e9f870a --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Collection.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// When affixes to a collection, prevent this collection's size to be modified by the inspector. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class CollectionAttribute : Attribute, IListAttribute + { + private int size = -1; + + /// <summary> + /// Size of this collection. + /// Default -1; size is not controlled by code. + /// 0 means the collection's size will be handled internally. + /// > 0 indicate the same of the collection. + /// </summary> + public int Size + { + get { return size; } + set { size = value; } + } + + private bool sortable = true; + + /// <summary> + /// If true, the list can be sorted by hand. + /// </summary> + public bool Sortable + { + get { return sortable; } + set { sortable = value; } + } + + private CollectionDisplay display = CollectionDisplay.List; + + /// <summary> + /// If not default, removes the collection list and only display one item at a time. + /// </summary> + public CollectionDisplay Display + { + get { return display; } + set { display = value; } + } + + private int maxDisplayedItems = 25; + + /// <summary> + /// When a collection is very large, it get up/down arrows to scrolls in items instead of displaying them all. + /// This property controls how many items are displayed before the scrolls appears. + /// </summary> + public int MaxDisplayedItems + { + get { return maxDisplayedItems; } + set { maxDisplayedItems = value; } + } + + private int maxItemsPerRow = 6; + + /// <summary> + /// When display is using Button, this is the maximum number of button displayed per rows before creating a new one. + /// </summary> + public int MaxItemsPerRow + { + get { return maxItemsPerRow; } + set { maxItemsPerRow = value; } + } + + private Type enumType = null; + + /// <summary> + /// Bind the size of a collection to the values of an enum. + /// The name of the indexed are displayed using the enum values' names. + /// </summary> + public Type EnumType + { + get { return enumType; } + set + { + if (!value.IsEnum) + return; + + int index = 0; + foreach (object i in Enum.GetValues(value)) + { + if ((int)i != index) + return; + + index++; + } + + enumType = value; + } + } + + public CollectionAttribute() { } + + public CollectionAttribute(int size) + : this(size, true) { } + + public CollectionAttribute(Type enumType) + : this(enumType, true) { } + + public CollectionAttribute(bool sortable) + : this(-1, sortable) { } + + public CollectionAttribute(CollectionDisplay display) + : this(-1, true, display) { } + + public CollectionAttribute(int size, bool sortable) + : this(size, sortable, CollectionDisplay.List) { } + + public CollectionAttribute(Type enumType, bool sortable) + : this(enumType, sortable, CollectionDisplay.List) { } + + public CollectionAttribute(int size, CollectionDisplay display) + : this(size, true, display) { } + + public CollectionAttribute(Type enumType, CollectionDisplay display) + : this(enumType, true, display) { } + + public CollectionAttribute(int size, bool sortable, CollectionDisplay display) + { + this.size = size; + this.sortable = sortable; + this.display = display; + } + + public CollectionAttribute(Type enumType, bool sortable, CollectionDisplay display) + { + this.EnumType = enumType; + this.sortable = sortable; + this.display = display; + } + } + + /// <summary> + /// None default display should only be used on collection that contain expandable objects. + /// </summary> + public enum CollectionDisplay + { + List, + DropDown, + Button + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Collection.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Collection.cs.meta new file mode 100644 index 00000000..3024d617 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Collection.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fca33267bb5f8b043a4dd1079e32af1c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Constructor.cs b/Assets/Plugins/AdvancedInspector/Attributes/Constructor.cs new file mode 100644 index 00000000..1b3f7438 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Constructor.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// Some object cannot be created with an empty constructor. + /// This runtime attribute lets you create the object by yourself. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class ConstructorAttribute : Attribute, IRuntimeAttribute<object> + { + public delegate object ConstructorDelegate(); + public delegate object ConstructorStaticDelegate(ConstructorAttribute constructor, object instance, object value); + + #region IRuntime Implementation + private string methodName = ""; + + public string MethodName + { + get { return methodName; } + } + + public Type Template + { + get { return typeof(ConstructorDelegate); } + } + + public Type TemplateStatic + { + get { return typeof(ConstructorStaticDelegate); } + } + + private List<Delegate> delegates = new List<Delegate>(); + + public List<Delegate> Delegates + { + get { return delegates; } + set { delegates = value; } + } + + public object Invoke(int index, object instance, object value) + { + if (delegates.Count == 0 || index >= delegates.Count) + return null; + + try + { + if (delegates[index].Target == null) + { + return delegates[index].DynamicInvoke(this, instance, value); + } + else + { + return delegates[index].DynamicInvoke(); + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + e = ((TargetInvocationException)e).InnerException; + + Debug.LogError(string.Format("Invoking a method from a constructor failed. The exception was \"{0}\".", e.Message)); + return null; + } + } + #endregion + + public ConstructorAttribute(string methodName) + { + this.methodName = methodName; + } + + public ConstructorAttribute(Delegate method) + { + this.delegates.Add(method); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Constructor.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Constructor.cs.meta new file mode 100644 index 00000000..f333c05f --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Constructor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8e27defafd172764c9e999b947b2f4e6 +timeCreated: 1426031598 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/CreateDerived.cs b/Assets/Plugins/AdvancedInspector/Attributes/CreateDerived.cs new file mode 100644 index 00000000..3fac45f8 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/CreateDerived.cs @@ -0,0 +1,15 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Define an exposed property that act as a object creator. + /// The field gives the user the choices of all type deriving from that property type. + /// In the case of a generic List, it offers way to add object in the list. + /// If the list is of a value type (Ex.: int), it automaticly create an entry with the default value of that type. + /// Field/Property's type sporting this attribute should derive from ComponentMonoBehaviour! + /// Otherwise, Unity's serialization will kill the polymorphism involved. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class CreateDerivedAttribute : Attribute, IListAttribute { } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/CreateDerived.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/CreateDerived.cs.meta new file mode 100644 index 00000000..2fcb841a --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/CreateDerived.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fe2444b9e8ef55340952cecad2cc75c0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Descriptor.cs b/Assets/Plugins/AdvancedInspector/Attributes/Descriptor.cs new file mode 100644 index 00000000..a452e72b --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Descriptor.cs @@ -0,0 +1,262 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// A description is the information about "something". + /// It contains an optional name, description, icon, color. + /// It can be used both as a attributes or a normal object, container of information. + /// Ex.: The Toolbox is using it as object. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class | + AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum, Inherited = false)] + public class DescriptorAttribute : Attribute, IRuntimeAttribute<DescriptorAttribute> + { + public delegate DescriptorAttribute DescriptorDelegate(); + public delegate DescriptorAttribute DescriptorStaticDelegate(DescriptorAttribute descriptor, object instance, object value); + + private static Color TRANSPARENT = new Color(0, 0, 0, 0); + + private string name = ""; + + /// <summary> + /// Give this item a name. + /// </summary> + public string Name + { + get { return name; } + set { name = value; } + } + + private string description = ""; + + /// <summary> + /// Give this item a description. + /// Usually used for tooltip. + /// </summary> + public string Description + { + get { return description; } + set { description = value; } + } + + private string url = ""; + + /// <summary> + /// Give this item an help URL. + /// </summary> + public string URL + { + get { return url; } + set { url = value; } + } + + private Texture icon = null; + + /// <summary> + /// Give this item an icon. + /// Useful in a list of items. + /// </summary> + public Texture Icon + { + get { return icon; } + set { icon = value; } + } + + private Color color = Color.clear; + + /// <summary> + /// Give this item a color. + /// Default is transparent + /// </summary> + public Color Color + { + get { return color; } + set { color = value; } + } + + #region IRuntime Implementation + private string methodName = ""; + + public string MethodName + { + get { return methodName; } + } + + public Type Template + { + get { return typeof(DescriptorDelegate); } + } + + public Type TemplateStatic + { + get { return typeof(DescriptorStaticDelegate); } + } + + private List<Delegate> delegates = new List<Delegate>(); + + public List<Delegate> Delegates + { + get { return delegates; } + set { delegates = value; } + } + + public DescriptorAttribute Invoke(int index, object instance, object value) + { + if (delegates.Count == 0 || index >= delegates.Count) + return this; + + try + { + if (delegates[index].Target == null) + { + return delegates[0].DynamicInvoke(this, instance, value) as DescriptorAttribute; + } + else + { + return delegates[0].DynamicInvoke() as DescriptorAttribute; + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + e = ((TargetInvocationException)e).InnerException; + + Debug.LogError(string.Format("Invoking a method to retrieve a Destriptor attribute failed. The exception was \"{0}\".", e.Message)); + return null; + } + } + #endregion + + public DescriptorAttribute() { } + + #region Attributes Constructor + public DescriptorAttribute(string methodName) + { + this.methodName = methodName; + } + + public DescriptorAttribute(float r, float g, float b) + : this("", "", "", r, g, b, 1) { } + + public DescriptorAttribute(string name, string description) + : this(name, description, "", 0, 0, 0, 0) { } + + public DescriptorAttribute(string name, string description, string url) + : this(name, description, url, 0, 0, 0, 0) { } + + public DescriptorAttribute(string name, string description, string url, float r, float g, float b) + : this(name, description, url, r, g, b, 1) { } + + private DescriptorAttribute(string name, string description, string url, float r, float g, float b, float a) + { + this.name = name; + this.description = description; + this.url = url; + color = new Color(r, g, b, a); + } + #endregion + + #region Object Constructor + public DescriptorAttribute(string name, string description, Texture icon) + : this(name, description, icon, TRANSPARENT) { } + + public DescriptorAttribute(string name, string description, Texture icon, Color color) + { + this.name = name; + this.description = description; + this.icon = icon; + this.color = color; + } + #endregion + + public static DescriptorAttribute GetDescriptor(Type type) + { + object[] obj = type.GetCustomAttributes(typeof(DescriptorAttribute), true); + + if (obj.Length == 0) + return null; + else + return (obj[0] as DescriptorAttribute); + } + + public static List<DescriptorAttribute> GetDescriptors(List<Type> types) + { + List<DescriptorAttribute> descriptors = new List<DescriptorAttribute>(); + + foreach (Type type in types) + descriptors.Add(GetDescriptor(type)); + + return descriptors; + } + } + + /// <summary> + /// Pairs an object with a descriptor. + /// Used by the Toolbox and the Advanced Inspector. + /// </summary> + public class DescriptorPair + { + private object value; + + public object Value + { + get { return value; } + } + + private DescriptorAttribute descriptor; + + public DescriptorAttribute Descriptor + { + get { return descriptor; } + } + + public DescriptorPair(object value, DescriptorAttribute descriptor) + { + this.value = value; + this.descriptor = descriptor; + } + + public DescriptorPair(object value, string name) + : this(value, new DescriptorAttribute(name, "")) { } + + public DescriptorPair(object value, string name, string description) + : this(value, new DescriptorAttribute(name, description)) { } + + public static bool operator ==(DescriptorPair a, DescriptorPair b) + { + // If both are null, or both are same instance, return true. + if (System.Object.ReferenceEquals(a, b)) + return true; + + // If one is null, but not both, return false. + if (((object)a == null) || ((object)b == null)) + return false; + + return a.Equals(b); + } + + public static bool operator !=(DescriptorPair a, DescriptorPair b) + { + return !(a == b); + } + + public override bool Equals(object obj) + { + DescriptorPair other = obj as DescriptorPair; + if (other == null) + return false; + + return this.Value.Equals(other.Value); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Descriptor.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Descriptor.cs.meta new file mode 100644 index 00000000..eee13f0a --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Descriptor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c543914d76893214f9fceba693c0ed76 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/DisplayAsParent.cs b/Assets/Plugins/AdvancedInspector/Attributes/DisplayAsParent.cs new file mode 100644 index 00000000..acec32e9 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/DisplayAsParent.cs @@ -0,0 +1,10 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Prevent a nested object from having to be unfolded. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class DisplayAsParentAttribute : Attribute { } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/DisplayAsParent.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/DisplayAsParent.cs.meta new file mode 100644 index 00000000..3632a07b --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/DisplayAsParent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3fca13597b0728d41a25aa9d670f0b86 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/DontAllowSceneObject.cs b/Assets/Plugins/AdvancedInspector/Attributes/DontAllowSceneObject.cs new file mode 100644 index 00000000..7c8506a6 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/DontAllowSceneObject.cs @@ -0,0 +1,11 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Prevent Scene Object from being browsed in a Object property. + /// By default, scene and asset are displayed. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class DontAllowSceneObjectAttribute : Attribute, IListAttribute { } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/DontAllowSceneObject.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/DontAllowSceneObject.cs.meta new file mode 100644 index 00000000..72b6f6c1 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/DontAllowSceneObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 819e08560dc14324ebaa532c3f65751a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Enum.cs b/Assets/Plugins/AdvancedInspector/Attributes/Enum.cs new file mode 100644 index 00000000..f9b88281 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Enum.cs @@ -0,0 +1,68 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Controls how an enum is handled and displayed. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class EnumAttribute : Attribute, IListAttribute + { + private bool masked = false; + + /// <summary> + /// Turns a normal enum into a bitfield. + /// Careful, your enum should be properly setup to accepted bitfield input. + /// </summary> + public bool Masked + { + get { return masked; } + set { masked = value; } + } + + private EnumDisplay display = EnumDisplay.DropDown; + + /// <summary> + /// Forces an enum to be displayed differently. + /// </summary> + public EnumDisplay Display + { + get { return display; } + set { display = value; } + } + + private int maxItemsPerRow = 6; + + /// <summary> + /// When display is using Button or Checkbox, this is the maximum number of button displayed per rows before creating a new one. + /// </summary> + public int MaxItemsPerRow + { + get { return maxItemsPerRow; } + set { maxItemsPerRow = value; } + } + + public EnumAttribute(bool masked) + { + this.masked = masked; + } + + public EnumAttribute(EnumDisplay display) + { + this.display = display; + } + + public EnumAttribute(bool masked, EnumDisplay display) + { + this.masked = masked; + this.display = display; + } + } + + public enum EnumDisplay + { + DropDown, + Button, + Checkbox + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Enum.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Enum.cs.meta new file mode 100644 index 00000000..d47eb345 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Enum.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6bb7fceb011c74e43a49f0124591cb7e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Expandable.cs b/Assets/Plugins/AdvancedInspector/Attributes/Expandable.cs new file mode 100644 index 00000000..b63d5c38 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Expandable.cs @@ -0,0 +1,46 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Redefine if a field/property can be expanded or not. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = true)] + public class ExpandableAttribute : Attribute, IListAttribute + { + private bool expanded = false; + + /// <summary> + /// Makes the item expanded by default. + /// </summary> + public bool Expanded + { + get { return expanded; } + set { expanded = value; } + } + + private bool expandable = true; + + /// <summary> + /// Default true, can force a field to not be expandable. + /// </summary> + public bool Expandable + { + get { return expandable; } + set { expandable = value; } + } + + public ExpandableAttribute() { } + + public ExpandableAttribute(bool expandable) + { + this.expandable = expandable; + } + + public ExpandableAttribute(bool expandable, bool expanded) + { + this.expanded = expanded; + this.expandable = expandable; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Expandable.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Expandable.cs.meta new file mode 100644 index 00000000..60aef708 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Expandable.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 574c9c65c35362d4c81087ea01d49be7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/FieldEditor.cs b/Assets/Plugins/AdvancedInspector/Attributes/FieldEditor.cs new file mode 100644 index 00000000..b5c833d9 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/FieldEditor.cs @@ -0,0 +1,26 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Can only be placed a classed derived from FieldEditor, or a field/property taking a specific editor. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class FieldEditorAttribute : Attribute, IListAttribute + { + private string type = ""; + + /// <summary> + /// Type's name of the FieldEditor to use. + /// </summary> + public string Type + { + get { return type; } + } + + public FieldEditorAttribute(string type) + { + this.type = type; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/FieldEditor.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/FieldEditor.cs.meta new file mode 100644 index 00000000..7be7565f --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/FieldEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 48265bc16ba070a4f9c105cdd29d2805 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Group.cs b/Assets/Plugins/AdvancedInspector/Attributes/Group.cs new file mode 100644 index 00000000..e95709ad --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Group.cs @@ -0,0 +1,110 @@ +using System; +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// Allow to groups inspector items. + /// </summary> + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Method)] + public class GroupAttribute : Attribute + { + private string name = ""; + + /// <summary> + /// Name of the group. + /// </summary> + public string Name + { + get { return name; } + set { name = value; } + } + + private string description = ""; + + /// <summary> + /// Extra text for the group, displayed on the right side. + /// </summary> + public string Description + { + get { return description; } + set { description = value; } + } + + private string style = ""; + + /// <summary> + /// Style of this group. + /// Only need to be flagged on one item. + /// </summary> + public string Style + { + get { return style; } + set { style = value; } + } + + private int priority = 0; + + /// <summary> + /// Priority of this group when sorting items. + /// Only need to be flagged on one item. + /// </summary> + public int Priority + { + get { return priority; } + set { priority = value; } + } + + private bool expandable = true; + + /// <summary> + /// If false, the group is always expanded and does not have an foldout arrow. + /// </summary> + public bool Expandable + { + get { return expandable; } + set { expandable = value; } + } + + private Color color = Color.clear; + + /// <summary> + /// Give this item's background a color. + /// </summary> + public Color Color + { + get { return color; } + set { color = value; } + } + + public GroupAttribute(string name) + : this(name, "", 0) { } + + public GroupAttribute(string name, int priority) + : this(name, "", priority) { } + + public GroupAttribute(string name, string style) + : this(name, style, 0) { } + + public GroupAttribute(string name, float r, float g, float b) + : this(name, "", "", 0, r, g, b, 1) { } + + public GroupAttribute(string name, string style, int priority) + : this(name, "", style, priority, 0, 0, 0, 0) { } + + public GroupAttribute(string name, string style, float r, float g, float b) + : this(name, "", style, 0, r, g, b, 1) { } + + public GroupAttribute(string name, string style, int priority, float r, float g, float b) + : this(name, "", style, priority, r, g, b, 1) { } + + public GroupAttribute(string name, string description, string style, int priority, float r, float g, float b, float a) + { + this.name = name; + this.description = description; + this.style = style; + this.priority = priority; + this.color = new Color(r, g, b, a); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Group.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Group.cs.meta new file mode 100644 index 00000000..2a0b75a8 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Group.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 363188602a056ed47970a96a0f55d619 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Help.cs b/Assets/Plugins/AdvancedInspector/Attributes/Help.cs new file mode 100644 index 00000000..ea4825d9 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Help.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// When a property is flagged this way, a help box is added after the inspector's field. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true)] + public class HelpAttribute : Attribute, IRuntimeAttribute<HelpAttribute> + { + public const string IsNull = "HelpAttribute.IsValueNull"; + public const string IsNullOrEmpty = "HelpAttribute.IsStringNullOrEmpty"; + public const string IsMatch = "HelpAttribute.IsRegexMatch"; + + + public delegate HelpAttribute HelpDelegate(); + public delegate HelpAttribute HelpStaticDelegate(HelpAttribute help, object instance, object value); + + private HelpType type; + + /// <summary> + /// Help type. + /// Displays a specific icon. + /// </summary> + public HelpType Type + { + get { return type; } + set { type = value; } + } + + private string message; + + /// <summary> + /// Help message. + /// </summary> + public string Message + { + get { return message; } + set { message = value; } + } + + private HelpPosition position = HelpPosition.After; + + /// <summary> + /// By default, the helpbox is drawn after the field. + /// If this is false, it is drawn before the field. + /// </summary> + public HelpPosition Position + { + get { return position; } + set { position = value; } + } + + private string regex; + + /// <summary> + /// When using the IsRegex conditional, this string is used as a regular expresion. + /// </summary> + public string Regex + { + get { return regex; } + set { regex = value; } + } + + #region IRuntime Implementation + private string methodName = ""; + + public string MethodName + { + get { return methodName; } + } + + public Type Template + { + get { return typeof(HelpDelegate); } + } + + public Type TemplateStatic + { + get { return typeof(HelpStaticDelegate); } + } + + private List<Delegate> delegates = new List<Delegate>(); + + public List<Delegate> Delegates + { + get { return delegates; } + set { delegates = value; } + } + + public HelpAttribute Invoke(int index, object instance, object value) + { + if (delegates.Count == 0 || index >= delegates.Count) + return this; + + try + { + if (delegates[index].Target == null) + { + return delegates[0].DynamicInvoke(this, instance, value) as HelpAttribute; + } + else + { + return delegates[0].DynamicInvoke() as HelpAttribute; + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + e = ((TargetInvocationException)e).InnerException; + + Debug.LogError(string.Format("Invoking a method failed while trying to retrieve a Help attribute. The exception was \"{0}\".", e.Message)); + return null; + } + } + #endregion + + public HelpAttribute(string methodName) + : this(methodName, HelpType.None, HelpPosition.After, "") { } + + public HelpAttribute(string methodName, HelpType type, string message) + : this(methodName, type, HelpPosition.After, message) { } + + public HelpAttribute(HelpType type, string message) + : this("", type, HelpPosition.After, message) { } + + public HelpAttribute(HelpType type, HelpPosition position, string message) + : this("", type, position, message) { } + + public HelpAttribute(string methodName, HelpType type, HelpPosition position, string message) + { + this.methodName = methodName; + this.type = type; + this.position = position; + this.message = message; + } + + public HelpAttribute(Delegate method) + { + this.delegates.Add(method); + } + + private static HelpAttribute IsValueNull(HelpAttribute help, object instance, object value) + { + if (value == null || (value is UnityEngine.Object && ((UnityEngine.Object)value) == null)) + { + return help; + } + + return null; + } + + private static HelpAttribute IsStringNullOrEmpty(HelpAttribute help, object instance, object value) + { + if (value is string && string.IsNullOrEmpty((string)value)) + return help; + + return null; + } + + private static HelpAttribute IsRegexMatch(HelpAttribute help, object instance, object value) + { + if (value == null) + return null; + + string text = value.ToString(); + if (System.Text.RegularExpressions.Regex.IsMatch(text, help.regex)) + return help; + + return null; + } + } + + /// <summary> + /// Because the internal enum for help display is Editor only. + /// </summary> + public enum HelpType + { + None = 0, + Info = 1, + Warning = 2, + Error = 3, + } + + /// <summary> + /// The position where the help box should be placed. + /// </summary> + public enum HelpPosition + { + After, + Before + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Help.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Help.cs.meta new file mode 100644 index 00000000..1d663fe8 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Help.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d071ab40c60bc8a458f4e2578a30440e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Inspect.cs b/Assets/Plugins/AdvancedInspector/Attributes/Inspect.cs new file mode 100644 index 00000000..210e3558 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Inspect.cs @@ -0,0 +1,195 @@ +using System; +using System.Reflection; +using System.Collections.Generic; +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// Makes a property viewable in the Inspector of Unity. + /// Turns a method into a button in the Inspector. + /// You can input a conditional statement for your property to show up or not. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] + public class InspectAttribute : Attribute, IRuntimeAttribute<bool> + { + public delegate bool InspectDelegate(); + public delegate bool InspectStaticDelegate(InspectAttribute inspect, object instance, object value); + + private InspectorLevel level; + + /// <summary> + /// Inspector level are use to hide more advanced item. + /// Items under the current Inspector levels are hidden. + /// </summary> + public InspectorLevel Level + { + get { return level; } + set { level = value; } + } + + private bool condition = true; + + /// <summary> + /// Inverse the condition used by the IRuntime method. + /// </summary> + public bool Condition + { + get { return condition; } + set { condition = value; } + } + + private int priority = 0; + + /// <summary> + /// Priority of display of this item. + /// Smaller values are displayed first. Negative value are supported. + /// </summary> + public int Priority + { + get { return priority; } + set { priority = value; } + } + + #region IRuntime Implementation + private string methodName = ""; + + public string MethodName + { + get { return methodName; } + set { methodName = value; } + } + + public Type Template + { + get { return typeof(InspectDelegate); } + } + + public Type TemplateStatic + { + get { return typeof(InspectStaticDelegate); } + } + + private List<Delegate> delegates = new List<Delegate>(); + + public List<Delegate> Delegates + { + get { return delegates; } + set { delegates = value; } + } + + public bool Invoke(int index, object instance, object value) + { + if (delegates.Count == 0 || index >= delegates.Count) + return true; + + try + { + if (delegates[index].Target == null) + { + if (condition) + return (bool)delegates[index].DynamicInvoke(this, instance, value); + else + return !(bool)delegates[index].DynamicInvoke(this, instance, value); + } + else + { + if (condition) + return (bool)delegates[index].DynamicInvoke(); + else + return !(bool)delegates[index].DynamicInvoke(); + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + e = ((TargetInvocationException)e).InnerException; + + Debug.LogError(string.Format("Invoking a method to retrieve a Inspect attribute failed. The exception was \"{0}\".", e.Message)); + return true; + } + } + #endregion + + #region Compile Time Constructor + public InspectAttribute() + : this(InspectorLevel.Basic, "", true, 0) { } + + public InspectAttribute(int priority) + : this(InspectorLevel.Basic, "", true, priority) { } + + public InspectAttribute(InspectorLevel level) + : this(level, "", true, 0) { } + + public InspectAttribute(InspectorLevel level, int priority) + : this(level, "", true, priority) { } + + public InspectAttribute(InspectorLevel level, string methodName) + : this(level, methodName, true, 0) { } + + public InspectAttribute(InspectorLevel level, string methodName, int priority) + : this(level, methodName, true, priority) { } + + public InspectAttribute(InspectorLevel level, string methodName, bool condition) + : this(level, methodName, condition, 0) { } + + public InspectAttribute(string methodName) + : this(InspectorLevel.Basic, methodName, true, 0) { } + + public InspectAttribute(string methodName, int priority) + : this(InspectorLevel.Basic, methodName, true, priority) { } + + public InspectAttribute(string methodName, bool condition) + : this(InspectorLevel.Basic, methodName, condition, 0) { } + + public InspectAttribute(string methodName, bool condition, int priority) + : this(InspectorLevel.Basic, methodName, condition, priority) { } + + public InspectAttribute(InspectorLevel level, string methodName, bool condition, int priority) + { + this.level = level; + this.condition = condition; + this.methodName = methodName; + this.priority = priority; + } + #endregion + + #region Runtime Constructor + public InspectAttribute(Delegate method) + : this(InspectorLevel.Basic, method, true, 0) { } + + public InspectAttribute(Delegate method, int priority) + : this(InspectorLevel.Basic, method, true, priority) { } + + public InspectAttribute(Delegate method, bool condition) + : this(InspectorLevel.Basic, method, condition, 0) { } + + public InspectAttribute(Delegate method, bool condition, int priority) + : this(InspectorLevel.Basic, method, condition, priority) { } + + public InspectAttribute(InspectorLevel level, Delegate method) + : this(level, method, true, 0) { } + + public InspectAttribute(InspectorLevel level, Delegate method, int priority) + : this(level, method, true, priority) { } + + public InspectAttribute(InspectorLevel level, Delegate method, bool condition, int priority) + { + this.level = level; + this.condition = condition; + this.priority = priority; + this.delegates.Add(method); + } + #endregion + } + + /// <summary> + /// You can change or add your own levels. + /// </summary> + public enum InspectorLevel + { + Basic = 0, + Advanced = 1, + Debug = 2 + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Inspect.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Inspect.cs.meta new file mode 100644 index 00000000..f3b0b2fc --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Inspect.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b1d1add23978a924d9da822c16ecca5d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Method.cs b/Assets/Plugins/AdvancedInspector/Attributes/Method.cs new file mode 100644 index 00000000..df08abc8 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Method.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +namespace AdvancedInspector +{ + /// <summary> + /// Used when inspected a method, gives control over how it is displayed or handled. + /// </summary> + [AttributeUsage(AttributeTargets.Method)] + public class MethodAttribute : Attribute + { + private MethodDisplay display = MethodDisplay.Button; + + public MethodDisplay Display + { + get { return display; } + set { display = value; } + } + + public MethodAttribute() { } + + public MethodAttribute(MethodDisplay display) + { + this.display = display; + } + } + + + /// <summary> + /// How the method is displayed. + /// </summary> + public enum MethodDisplay + { + Button, // A button + Invoke // Invoke it so it draws its own stuff. + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Method.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Method.cs.meta new file mode 100644 index 00000000..7738c797 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Method.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d18c976511db4614f89166425f46b342 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/NoPicker.cs b/Assets/Plugins/AdvancedInspector/Attributes/NoPicker.cs new file mode 100644 index 00000000..0619ccec --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/NoPicker.cs @@ -0,0 +1,13 @@ +using UnityEngine; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + /// <summary> + /// Removes the object picking field from a selectable object. + /// Useful when the object is set internally, should be edited but not changed. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class NoPicker : Attribute, IListAttribute { } +} diff --git a/Assets/Plugins/AdvancedInspector/Attributes/NoPicker.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/NoPicker.cs.meta new file mode 100644 index 00000000..00643d66 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/NoPicker.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 76bfee0f7aa5c3e429aae6af201d0f66 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/RangeValue.cs b/Assets/Plugins/AdvancedInspector/Attributes/RangeValue.cs new file mode 100644 index 00000000..a0331216 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/RangeValue.cs @@ -0,0 +1,40 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Similar to Unity's "Range" attribute but for the Advanced Inspector. + /// However, Unity's version is flagged to be "Field Only", while this one can be placed on Properties. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class RangeValueAttribute : Attribute, IListAttribute + { + private float min; + + /// <summary> + /// Min value, the current value cannot go below that. + /// </summary> + public float Min + { + get { return min; } + set { min = value; } + } + + private float max; + + /// <summary> + /// Max value, the current value cannot go above that. + /// </summary> + public float Max + { + get { return max; } + set { max = value; } + } + + public RangeValueAttribute(float min, float max) + { + this.min = min; + this.max = max; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/RangeValue.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/RangeValue.cs.meta new file mode 100644 index 00000000..780732c1 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/RangeValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 214bf4d5f010cd14f8f02b9debfca40d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/ReadOnly.cs b/Assets/Plugins/AdvancedInspector/Attributes/ReadOnly.cs new file mode 100644 index 00000000..145f1167 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/ReadOnly.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// Makes a Property read only (cannot be modified) + /// It's grayed out in the inspector, even if there's a setter. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false)] + public class ReadOnlyAttribute : Attribute, IListAttribute, IRuntimeAttribute<bool> + { + public delegate bool ReadOnlyDelegate(); + public delegate bool ReadOnlyStaticDelegate(ReadOnlyAttribute readOnly, object instance, object value); + + #region IRuntime Implementation + private string methodName = ""; + + public string MethodName + { + get { return methodName; } + } + + public Type Template + { + get { return typeof(ReadOnlyDelegate); } + } + + public Type TemplateStatic + { + get { return typeof(ReadOnlyStaticDelegate); } + } + + private List<Delegate> delegates = new List<Delegate>(); + + public List<Delegate> Delegates + { + get { return delegates; } + set { delegates = value; } + } + + public bool Invoke(int index, object instance, object value) + { + if (delegates.Count == 0 || index >= delegates.Count) + return true; + + try + { + if (delegates[index].Target == null) + { + return (bool)delegates[index].DynamicInvoke(this, instance, value); + } + else + { + return (bool)delegates[index].DynamicInvoke(); + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + e = ((TargetInvocationException)e).InnerException; + + Debug.LogError(string.Format("Invoking a method to retrieve a ReadOnly attribute failed. The exception was \"{0}\".", e.Message)); + return false; + } + } + #endregion + + public ReadOnlyAttribute() { } + + public ReadOnlyAttribute(Delegate method) + { + this.delegates.Add(method); + } + + public ReadOnlyAttribute(string methodName) + { + this.methodName = methodName; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/ReadOnly.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/ReadOnly.cs.meta new file mode 100644 index 00000000..d0993047 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/ReadOnly.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 807b8f48dfd4f724d979f453c48556e1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Restrict.cs b/Assets/Plugins/AdvancedInspector/Attributes/Restrict.cs new file mode 100644 index 00000000..43d48f76 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Restrict.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// Restrict an object field to a list of object define by a delegate from the owner. + /// In essence, turn any field into a drop down list of choices. + /// Attributes cannot recieve a delegate, instead you pass the name of the method. + /// The method itself is resolved when creating the field to know which instance to invoke. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class RestrictAttribute : Attribute, IListAttribute, IRuntimeAttribute<IList> + { + public delegate IList RestrictDelegate(); + public delegate IList RestrictStaticDelegate(RestrictAttribute restrict, object instance, object value); + + private RestrictDisplay display = RestrictDisplay.DropDown; + + /// <summary> + /// Should this restricted field use the toolbox instead of a drop down popup. + /// </summary> + public RestrictDisplay Display + { + get { return display; } + set { display = value; } + } + + private int maxItemsPerRow = 6; + + /// <summary> + /// When display is using Button, limits the number of items per row. + /// </summary> + public int MaxItemsPerRow + { + get { return maxItemsPerRow; } + set { maxItemsPerRow = value; } + } + + #region IRuntime Implementation + private string methodName = ""; + + public string MethodName + { + get { return methodName; } + } + + public Type Template + { + get { return typeof(RestrictDelegate); } + } + + public Type TemplateStatic + { + get { return typeof(RestrictStaticDelegate); } + } + + private List<Delegate> delegates = new List<Delegate>(); + + public List<Delegate> Delegates + { + get { return delegates; } + set { delegates = value; } + } + + public IList Invoke(int index, object instance, object value) + { + if (delegates.Count == 0 || index >= delegates.Count) + return null; + + try + { + if (delegates[index].Target == null) + { + return delegates[index].DynamicInvoke(this, instance, value) as IList; + } + else + { + return delegates[index].DynamicInvoke() as IList; + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + e = ((TargetInvocationException)e).InnerException; + + Debug.LogError(string.Format("Invoking a method to retrieve a Restrict attribute data failed. The exception was \"{0}\".", e.Message)); + return null; + } + } + #endregion + + public RestrictAttribute(string methodName) + : this(methodName, RestrictDisplay.DropDown) { } + + public RestrictAttribute(string methodName, RestrictDisplay display) + { + this.methodName = methodName; + this.display = display; + } + + public RestrictAttribute(Delegate method) + : this(method, RestrictDisplay.DropDown) { } + + public RestrictAttribute(Delegate method, RestrictDisplay display) + { + this.delegates.Add(method); + this.display = display; + } + } + + public enum RestrictDisplay + { + DropDown, + Toolbox, + Button + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Restrict.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Restrict.cs.meta new file mode 100644 index 00000000..05cc475f --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Restrict.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f427a8594327b11458d6ebc38c5fc6b6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/RuntimeResolve.cs b/Assets/Plugins/AdvancedInspector/Attributes/RuntimeResolve.cs new file mode 100644 index 00000000..16a56fc4 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/RuntimeResolve.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// Forces a field to display a FieldEditor related to its current runtime type instead of the field type. + /// The Runtime version supply the type itself. Useful when the field value is null or for an unknown object picker. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class RuntimeResolveAttribute : Attribute, IListAttribute, IRuntimeAttribute<Type> + { + public delegate Type RuntimeResolveDelegate(); + public delegate Type RuntimeResolveStaticDelegate(RuntimeResolveAttribute runtimeResolve, object instance, object value); + + #region IRuntime Implementation + private string methodName = ""; + + public string MethodName + { + get { return methodName; } + } + + public Type Template + { + get { return typeof(RuntimeResolveDelegate); } + } + + public Type TemplateStatic + { + get { return typeof(RuntimeResolveStaticDelegate); } + } + + private List<Delegate> delegates = new List<Delegate>(); + + public List<Delegate> Delegates + { + get { return delegates; } + set { delegates = value; } + } + + public Type Invoke(int index, object instance, object value) + { + if (delegates.Count == 0 || index >= delegates.Count) + return null; + + try + { + if (delegates[index].Target == null) + { + return delegates[index].DynamicInvoke(this, instance, value) as Type; + } + else + { + return delegates[index].DynamicInvoke() as Type; + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + e = ((TargetInvocationException)e).InnerException; + + Debug.LogError(string.Format("Invoking a method from a RuntimeResolve attribute failed. The exception was \"{0}\".", e.Message)); + return null; + } + } + #endregion + + public RuntimeResolveAttribute() { } + + public RuntimeResolveAttribute(string methodName) + { + this.methodName = methodName; + } + + public RuntimeResolveAttribute(Delegate method) + { + this.delegates.Add(method); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/RuntimeResolve.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/RuntimeResolve.cs.meta new file mode 100644 index 00000000..8e5deeb7 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/RuntimeResolve.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c41d12d2aa0e9824c828bab3957ce2ea +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Space.cs b/Assets/Plugins/AdvancedInspector/Attributes/Space.cs new file mode 100644 index 00000000..02972663 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Space.cs @@ -0,0 +1,48 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Add a space after the current fields. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] + public class SpacingAttribute : Attribute + { + private int before = 0; + + /// <summary> + /// Size of the space to add before the item. + /// Default is 0. + /// </summary> + public int Before + { + get { return before; } + set { before = value; } + } + + private int after = 0; + + /// <summary> + /// Size of the space to add after the item. + /// Default is 1. + /// </summary> + public int After + { + get { return after; } + set { after = value; } + } + + public SpacingAttribute() { } + + public SpacingAttribute(int after) + { + this.after = after; + } + + public SpacingAttribute(int before, int after) + { + this.after = after; + this.before = before; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Space.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Space.cs.meta new file mode 100644 index 00000000..3c698339 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Space.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 342298f826c259a4f8efdca9740e39a6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Style.cs b/Assets/Plugins/AdvancedInspector/Attributes/Style.cs new file mode 100644 index 00000000..5ffa27ac --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Style.cs @@ -0,0 +1,43 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Allow to change the style of an field item. + /// </summary> + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Method)] + public class StyleAttribute : Attribute + { + private string style = ""; + + /// <summary> + /// Name of the style to use. + /// Must be findable by GUI.skin.Find() + /// </summary> + public string Style + { + get { return style; } + set { style = value; } + } + + private bool label = true; + + /// <summary> + /// Force or prevent the field's label from being displayed. + /// </summary> + public bool Label + { + get { return label; } + set { label = value; } + } + + public StyleAttribute(string style) + : this(style, true) { } + + public StyleAttribute(string style, bool label) + { + this.style = style; + this.label = label; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Style.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Style.cs.meta new file mode 100644 index 00000000..fcb288c0 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Style.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4345a0f2d3a3744d90ee1c995161357 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Tab.cs b/Assets/Plugins/AdvancedInspector/Attributes/Tab.cs new file mode 100644 index 00000000..a7efea4d --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Tab.cs @@ -0,0 +1,25 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// The tabs allows to create a collection of tabs at the top based on an Enum's values. + /// Hides or shows items that are part of the selected tab. + /// </summary> + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Method)] + public class TabAttribute : Attribute + { + private Enum tab; + + public Enum Tab + { + get { return tab; } + set { tab = value; } + } + + public TabAttribute(object tab) + { + this.tab = (Enum)tab; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Tab.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Tab.cs.meta new file mode 100644 index 00000000..4c19797c --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Tab.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b3a31f241bcc75944a1919a273e85010 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/TextField.cs b/Assets/Plugins/AdvancedInspector/Attributes/TextField.cs new file mode 100644 index 00000000..555fa1cb --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/TextField.cs @@ -0,0 +1,87 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// This allows control over how a string field is displayed. + /// Only useful on string field. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class TextFieldAttribute : Attribute, IListAttribute + { + private const string TITLE = "Select Path..."; + private const string PATH = ""; + private const string EXTENSION = ""; + + private string title = ""; + + /// <summary> + /// Title of the modal dialog + /// </summary> + public string Title + { + get { return title; } + set { title = value; } + } + + private string path = "C:\\"; + + /// <summary> + /// Default file/folder path + /// </summary> + public string Path + { + get { return path; } + set { path = value; } + } + + private string extension = ""; + + /// <summary> + /// Force the file dialog to show only specific file type. + /// </summary> + public string Extension + { + get { return extension; } + set { extension = value; } + } + + private TextFieldType type; + + /// <summary> + /// What type of control is this string. + /// </summary> + public TextFieldType Type + { + get { return type; } + set { type = value; } + } + + public TextFieldAttribute(TextFieldType type) + : this(type, TITLE, PATH, EXTENSION) { } + + public TextFieldAttribute(TextFieldType type, string title) + : this(type, title, PATH, EXTENSION) { } + + public TextFieldAttribute(TextFieldType type, string title, string path) + : this(type, title, path, EXTENSION) { } + + public TextFieldAttribute(TextFieldType type, string title, string path, string extension) + { + this.type = type; + this.title = title; + this.path = path; + this.extension = extension; + } + } + + public enum TextFieldType + { + Standard, + Password, + Area, + Tag, + File, + Folder + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/TextField.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/TextField.cs.meta new file mode 100644 index 00000000..9aeb2b82 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/TextField.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce81aa34d03e9e84a981812d142a46a1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Title.cs b/Assets/Plugins/AdvancedInspector/Attributes/Title.cs new file mode 100644 index 00000000..2330db37 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Title.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Linq; +using System.Text; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// Similar to Unity "Header" attribute, but can be place on any members and be set at runtime. + /// </summary> + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] + public class TitleAttribute : Attribute, IRuntimeAttribute<TitleAttribute> + { + public delegate TitleAttribute TitleDelegate(); + public delegate TitleAttribute TitleStaticDelegate(TitleAttribute title, object instance, object value); + + private string message; + + /// <summary> + /// The title message + /// </summary> + public string Message + { + get { return message; } + set { message = value; } + } + + private FontStyle style = FontStyle.Bold; + + /// <summary> + /// The font style. + /// </summary> + public FontStyle Style + { + get { return style; } + set { style = value; } + } + + #region IRuntime Implementation + private string methodName = ""; + + public string MethodName + { + get { return methodName; } + } + + public Type Template + { + get { return typeof(TitleDelegate); } + } + + public Type TemplateStatic + { + get { return typeof(TitleStaticDelegate); } + } + + private List<Delegate> delegates = new List<Delegate>(); + + public List<Delegate> Delegates + { + get { return delegates; } + set { delegates = value; } + } + + public TitleAttribute Invoke(int index, object instance, object value) + { + if (delegates.Count == 0 || index >= delegates.Count) + return this; + + try + { + if (delegates[index].Target == null) + { + return delegates[0].DynamicInvoke(this, instance, value) as TitleAttribute; + } + else + { + return delegates[0].DynamicInvoke() as TitleAttribute; + } + } + catch (Exception e) + { + if (e is TargetInvocationException) + e = ((TargetInvocationException)e).InnerException; + + Debug.LogError(string.Format("Invoking a method failed while trying to retrieve a Title attribute. The exception was \"{0}\".", e.Message)); + return null; + } + } + #endregion + + public TitleAttribute(string methodName) + { + this.methodName = methodName; + } + + public TitleAttribute(FontStyle style, string message) + { + this.style = style; + this.message = message; + } + + public TitleAttribute(Delegate method) + { + this.delegates.Add(method); + } + } +} diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Title.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Title.cs.meta new file mode 100644 index 00000000..f0377be3 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Title.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 50a11bb467421824c95d21c7fb6d8073 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Toolbar.cs b/Assets/Plugins/AdvancedInspector/Attributes/Toolbar.cs new file mode 100644 index 00000000..8044b984 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Toolbar.cs @@ -0,0 +1,108 @@ +using System; + +namespace AdvancedInspector +{ + /// <summary> + /// Allow to groups inspector items. + /// </summary> + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Method)] + public class ToolbarAttribute : Attribute + { + public const string ToolbarStyle = "Toolbar"; + + private string name = ""; + + /// <summary> + /// Name of the toolbar, used to group items. + /// If Label is true, the name is displayed. + /// </summary> + public string Name + { + get { return name; } + set { name = value; } + } + + private string style = ""; + + /// <summary> + /// Style of this toolbar. Defaul; "Toolbar" + /// Only need to be flagged on one item. + /// </summary> + public string Style + { + get { return style; } + set { style = value; } + } + + private bool label = false; + + /// <summary> + /// Show or hide the toolbar label + /// Only need to be flagged on one item. + /// </summary> + public bool Label + { + get { return label; } + set { label = value; } + } + + private bool flexible = false; + + /// <summary> + /// This specific item will have a Flexible Space before + /// </summary> + public bool Flexible + { + get { return flexible; } + set { flexible = value; } + } + + private int priority = 0; + + /// <summary> + /// Priority of this toolbar when sorting items. + /// Only need to be flagged on one item. + /// </summary> + public int Priority + { + get { return priority; } + set { priority = value; } + } + + public ToolbarAttribute(string name) + : this(name, "", false, false, 0) { } + + public ToolbarAttribute(string name, int priority) + : this(name, "", false, false, priority) { } + + public ToolbarAttribute(string name, string style) + : this(name, style, false, false, 0) { } + + public ToolbarAttribute(string name, string style, int priority) + : this(name, style, false, false, priority) { } + + public ToolbarAttribute(string name, bool label) + : this(name, "", label, false, 0) { } + + public ToolbarAttribute(string name, bool label, int priority) + : this(name, "", label, false, priority) { } + + public ToolbarAttribute(string name, string style, bool label) + : this(name, style, label, false, 0) { } + + public ToolbarAttribute(string name, string style, bool label, int priority) + : this(name, style, label, false, priority) { } + + public ToolbarAttribute(string name, string style, bool label, bool flexible) + : this(name, style, label, flexible, 0) { } + + public ToolbarAttribute(string name, string style, bool label, bool flexible, int priority) + { + this.name = name; + this.style = style; + this.label = label; + this.flexible = flexible; + this.priority = priority; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Toolbar.cs.meta b/Assets/Plugins/AdvancedInspector/Attributes/Toolbar.cs.meta new file mode 100644 index 00000000..1b49b862 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Attributes/Toolbar.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 03350da06d5fe9643b20b6796771ad56 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Core.meta b/Assets/Plugins/AdvancedInspector/Core.meta new file mode 100644 index 00000000..c6c63969 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 0d71452a5ed8d3c4a9a83a9e27d4d2bd +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/AdvancedInspector/Core/ActionBinding.cs b/Assets/Plugins/AdvancedInspector/Core/ActionBinding.cs new file mode 100644 index 00000000..55573bbd --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/ActionBinding.cs @@ -0,0 +1,744 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// This class represent an event, and allows the Inspector to bind it to another method. + /// Arguments can be sent to the invoked method from a static field, internal from the code invoking, or from another method returned value. + /// </summary> + [Serializable, AdvancedInspector] + public class ActionBinding : ICopiable + { + [SerializeField] + private string[] internalParameters = new string[0]; + + [SerializeField] + private GameObject gameObject; + + [Inspect] + public GameObject GameObject + { + get { return gameObject; } + set + { + if (gameObject != value) + { + gameObject = value; + Component = null; + } + } + } + + [SerializeField] + private Component component; + + [Inspect, Restrict("GetComponents")] + public Component Component + { + get { return component; } + set + { + if (component != value) + { + component = value; + Method = null; + } + } + } + + private IList GetComponents() + { + List<DescriptorPair> components = new List<DescriptorPair>(); + if (gameObject == null) + return components; + + foreach (Component component in gameObject.GetComponents(typeof(Component))) + components.Add(new DescriptorPair(component, new DescriptorAttribute(component.GetType().Name, ""))); + + return components; + } + + [SerializeField] + private string method; + + [Inspect, Restrict("GetMethods", RestrictDisplay.Toolbox)] + public MethodInfo Method + { + get { return GetMethodInfo(); } + set + { + if (value == null) + { + parameters = new BindingParameter[0]; + method = ""; + return; + } + + MethodInfo info = GetMethodInfo(); + if (info != value) + { + method = value.Name; + ParameterInfo[] param = value.GetParameters(); + parameters = new BindingParameter[param.Length]; + for (int i = 0; i < param.Length; i++) + { + parameters[i] = new BindingParameter(internalParameters.Length > i); + parameters[i].Type = param[i].ParameterType; + if (internalParameters.Length > i) + parameters[i].binding = BindingParameter.BindingType.Internal; + } + } + } + } + + private IList GetMethods() + { + List<DescriptorPair> methods = new List<DescriptorPair>(); + if (gameObject == null || component == null) + return methods; + + foreach (MethodInfo info in component.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)) + { + if (info.IsGenericMethod || info.IsConstructor || info.IsFinal || info.IsSpecialName || info.DeclaringType == typeof(object) || info.DeclaringType == typeof(Component)) + continue; + + if (!IsMethodValid(info)) + continue; + + ParameterInfo[] param = info.GetParameters(); + + methods.Add(new DescriptorPair(info, new DescriptorAttribute(GetParamNames(info.Name, param), ""))); + } + + foreach (PropertyInfo info in component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)) + { + if (!info.CanWrite || info.DeclaringType == typeof(object) || info.DeclaringType == typeof(UnityEngine.Object) || info.DeclaringType == typeof(Component)) + continue; + + MethodInfo method = info.GetSetMethod(); + if (method == null || !IsMethodValid(method)) + continue; + + ParameterInfo[] param = method.GetParameters(); + + methods.Add(new DescriptorPair(method, new DescriptorAttribute(GetParamNames(info.Name, param), ""))); + } + + return methods; + } + + private bool IsMethodValid(MethodInfo info) + { + ParameterInfo[] param = info.GetParameters(); + + bool valid = true; + for (int i = 0; i < param.Length; i++) + { + if (!BindingParameter.IsValidType(param[i].ParameterType)) + { + valid = false; + break; + } + + if (internalParameters.Length > i) + { + Type type = Type.GetType(internalParameters[i]); + if (!type.IsAssignableFrom(param[i].ParameterType)) + { + valid = false; + break; + } + } + } + + return valid; + } + + private string GetParamNames(string name, ParameterInfo[] param) + { + string paramName = name + " ("; + for (int i = 0; i < param.Length; i++) + { + paramName += param[i].ParameterType.Name; + if (i < param.Length - 1) + paramName += ", "; + } + paramName += ")"; + + return paramName; + } + + private MethodInfo GetMethodInfo() + { + if (gameObject == null || component == null || string.IsNullOrEmpty(method)) + return null; + + Type[] types = new Type[parameters.Length]; + for (int i = 0; i < parameters.Length; i++) + types[i] = parameters[i].Type; + + return component.GetType().GetMethod(method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy, null, types, null); + } + + [Inspect, Collection(0, false), SerializeField] + private BindingParameter[] parameters = new BindingParameter[0]; + + public event ActionEventHandler OnInvoke; + + /// <summary> + /// Parameter-less method constructor. + /// </summary> + public ActionBinding() { } + + /// <summary> + /// The array of types is the method definition. + /// Method with the wrong parameters are not selectable. + /// </summary> + public ActionBinding(Type[] types) + { + internalParameters = new string[types.Length]; + for (int i = 0; i < types.Length; i++) + internalParameters[i] = types[i].AssemblyQualifiedName; + } + + /// <summary> + /// Invoke the method. + /// Be careful to pass the proper type as args, otherwise they will be ignored. + /// Args are only retained if the parameter is flagged as internal. + /// </summary> + public void Invoke(params object[] args) + { + if (gameObject == null || component == null || string.IsNullOrEmpty(method)) + return; + + MethodInfo info = GetMethodInfo(); + if (info == null) + return; + + object[] values = new object[parameters.Length]; + for (int i = 0; i < parameters.Length; i++) + { + if (args.Length > i && parameters[i].binding == BindingParameter.BindingType.Internal) + values[i] = args[i]; + else + values[i] = parameters[i].Value; + } + + info.Invoke(component, values); + + if (OnInvoke != null) + OnInvoke(this, values); + } + + public override string ToString() + { + string supplied = "("; + for (int i = 0; i < internalParameters.Length; i++) + { + supplied += Type.GetType(internalParameters[i]).Name; + if (i < internalParameters.Length - 1) + supplied += ", "; + } + + supplied += ")"; + + if (component != null) + return component.GetType().Name + " : " + method + " : " + supplied; + else + return supplied; + } + + public bool Copiable(object destination) + { + ActionBinding action = destination as ActionBinding; + if (action == null) + return false; + + if (action.internalParameters.Length != internalParameters.Length) + return false; + + for (int i = 0; i < internalParameters.Length; i++) + if (internalParameters[i] != action.internalParameters[i]) + return false; + + return true; + } + + /// <summary> + /// The binding parameter define how each of the argument of the invoked method is handled. + /// </summary> + [Serializable, AdvancedInspector] + public class BindingParameter : ICopy, ICopiable + { + [Inspect(-1), Restrict("RestrictBinding")] + public BindingType binding; + + private IList RestrictBinding() + { + List<object> list = new List<object>(); + if (canBeInternal) + list.Add(BindingType.Internal); + + list.Add(BindingType.Static); + list.Add(BindingType.External); + return list; + } + + private bool canBeInternal = true; + + private bool CanBeInternal + { + get { return canBeInternal; } + } + + #region Values + [SerializeField] + private BindingValueType type; + + [SerializeField] + private string qualifiedTypeName; + + public Type Type + { + get + { + if (string.IsNullOrEmpty(qualifiedTypeName)) + return null; + else + return Type.GetType(qualifiedTypeName); + } + + set + { + if (value == typeof(bool)) + type = BindingValueType.Boolean; + else if (value == typeof(Bounds)) + type = BindingValueType.Bounds; + else if (value == typeof(Color)) + type = BindingValueType.Color; + else if (value == typeof(float)) + type = BindingValueType.Float; + else if (value == typeof(int)) + type = BindingValueType.Integer; + else if (value == typeof(Rect)) + type = BindingValueType.Rect; + else if (typeof(UnityEngine.Object).IsAssignableFrom(value)) + type = BindingValueType.Reference; + else if (value == typeof(string)) + type = BindingValueType.String; + else if (value == typeof(Vector2)) + type = BindingValueType.Vector2; + else if (value == typeof(Vector3)) + type = BindingValueType.Vector3; + else if (value == typeof(Vector4)) + type = BindingValueType.Vector4; + else + type = BindingValueType.None; + + if (type != BindingValueType.None) + qualifiedTypeName = value.AssemblyQualifiedName; + else + qualifiedTypeName = ""; + } + } + + [Inspect(-2)] + public string BoundType + { + get + { + if (Type == null) + return ""; + + return Type.Name; + } + } + + [SerializeField] + private bool boolValue = false; + [SerializeField] + private int intValue = 0; + [SerializeField] + private float floatValue = 0; + [SerializeField] + private string stringValue = ""; + [SerializeField] + private Vector2 vector2Value = Vector2.zero; + [SerializeField] + private Vector3 vector3Value = Vector3.zero; + [SerializeField] + private Vector4 vector4Value = Vector4.zero; + [SerializeField] + private Color colorValue = Color.black; + [SerializeField] + private Rect rectValue = new Rect(0, 0, 0, 0); + [SerializeField] + private Bounds boundsValue = new Bounds(Vector3.zero, Vector3.zero); + [SerializeField] + private UnityEngine.Object referenceValue = new UnityEngine.Object(); + #endregion + + [Inspect("IsStatic")] + [RuntimeResolve("GetRuntimeType")] + public object Value + { + get + { + if (binding == BindingType.External) + { + object value = Invoke(); + if (value.GetType().IsAssignableFrom(Type)) + return value; + + System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(Type); + return converter.ConvertTo(value, Type); + } + + switch (type) + { + case BindingValueType.Boolean: + return boolValue; + case BindingValueType.Bounds: + return boundsValue; + case BindingValueType.Color: + return colorValue; + case BindingValueType.Float: + return floatValue; + case BindingValueType.Integer: + return intValue; + case BindingValueType.Rect: + return rectValue; + case BindingValueType.Reference: + return referenceValue; + case BindingValueType.String: + return stringValue; + case BindingValueType.Vector2: + return vector2Value; + case BindingValueType.Vector3: + return vector3Value; + case BindingValueType.Vector4: + return vector4Value; + default: + return null; + } + } + + set + { + if (value == null && type != BindingValueType.Reference) + return; + + switch (type) + { + case BindingValueType.Boolean: + boolValue = (bool)value; + break; + case BindingValueType.Bounds: + boundsValue = (Bounds)value; + break; + case BindingValueType.Color: + colorValue = (Color)value; + break; + case BindingValueType.Float: + floatValue = (float)value; + break; + case BindingValueType.Integer: + intValue = (int)value; + break; + case BindingValueType.Rect: + rectValue = (Rect)value; + break; + case BindingValueType.Reference: + referenceValue = (UnityEngine.Object)value; + break; + case BindingValueType.String: + stringValue = (string)value; + break; + case BindingValueType.Vector2: + vector2Value = (Vector2)value; + break; + case BindingValueType.Vector3: + vector3Value = (Vector3)value; + break; + case BindingValueType.Vector4: + vector4Value = (Vector4)value; + break; + default: + return; + } + } + } + + [SerializeField] + private GameObject gameObject; + + [Inspect("IsExternal")] + public GameObject GameObject + { + get { return gameObject; } + set + { + if (gameObject != value) + { + gameObject = value; + Component = null; + } + } + } + + [SerializeField] + private Component component; + + [Inspect("IsExternal")] + [Restrict("GetComponents")] + public Component Component + { + get { return component; } + set + { + if (component != value) + { + component = value; + Method = null; + } + } + } + + private IList GetComponents() + { + List<DescriptorPair> components = new List<DescriptorPair>(); + if (gameObject == null) + return components; + + foreach (Component component in gameObject.GetComponents(typeof(Component))) + components.Add(new DescriptorPair(component, new DescriptorAttribute(component.GetType().Name, ""))); + + return components; + } + + [SerializeField] + private string method; + + [Inspect("IsExternal")] + [Restrict("GetMethods", RestrictDisplay.Toolbox)] + public MethodInfo Method + { + get { return GetMethodInfo(); } + set + { + if (value == null) + { + method = ""; + return; + } + + MethodInfo info = GetMethodInfo(); + if (info != value) + method = value.Name; + } + } + + private IList GetMethods() + { + List<DescriptorPair> methods = new List<DescriptorPair>(); + if (gameObject == null || component == null) + return methods; + + foreach (MethodInfo info in component.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)) + { + if (info.IsGenericMethod || info.IsConstructor || info.IsFinal || info.IsSpecialName) + continue; + + if (!IsMethodValid(info)) + continue; + + string paramName = info.ReturnType.Name + " " + info.Name + "()"; + methods.Add(new DescriptorPair(info, new DescriptorAttribute(paramName, ""))); + } + + foreach (PropertyInfo info in component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)) + { + if (!info.CanRead) + continue; + + MethodInfo method = info.GetGetMethod(); + if (method == null || !IsMethodValid(method)) + continue; + + string paramName = method.ReturnType.Name + " " + info.Name + "()"; + methods.Add(new DescriptorPair(method, new DescriptorAttribute(paramName, ""))); + } + + return methods; + } + + private bool IsMethodValid(MethodInfo info) + { + ParameterInfo[] param = info.GetParameters(); + if (param.Length > 0) + return false; + + if (info.ReturnType == null || info.ReturnType == typeof(void)) + return false; + + System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(info.ReturnType); + if (!Type.IsAssignableFrom(info.ReturnType) && !converter.CanConvertTo(Type)) + return false; + + return true; + } + + private MethodInfo GetMethodInfo() + { + if (gameObject == null || component == null || string.IsNullOrEmpty(method)) + return null; + + return component.GetType().GetMethod(method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); + } + + private bool IsStatic() + { + return binding == BindingType.Static; + } + + private bool IsExternal() + { + return binding == BindingType.External; + } + + private Type GetRuntimeType() + { + return Type; + } + + public BindingParameter() { } + + public BindingParameter(bool canBeInternal) + { + this.canBeInternal = canBeInternal; + } + + public static bool IsValidType(Type type) + { + if (type == typeof(bool)) + return true; + else if (type == typeof(Bounds)) + return true; + else if (type == typeof(Color)) + return true; + else if (type == typeof(float)) + return true; + else if (type == typeof(int)) + return true; + else if (type == typeof(Rect)) + return true; + else if (typeof(UnityEngine.Object).IsAssignableFrom(type)) + return true; + else if (type == typeof(string)) + return true; + else if (type == typeof(Vector2)) + return true; + else if (type == typeof(Vector3)) + return true; + else if (type == typeof(Vector4)) + return true; + + return false; + } + + public enum BindingType + { + Internal, + Static, + External + } + + private enum BindingValueType + { + None, + + Boolean, + Integer, + Float, + String, + Vector2, + Vector3, + Vector4, + Color, + Rect, + Bounds, + Reference + } + + private object Invoke() + { + if (gameObject == null || component == null || string.IsNullOrEmpty(method)) + return null; + + MethodInfo info = GetMethodInfo(); + if (info == null) + return null; + + return info.Invoke(component, new object[0]); + } + + public bool Copiable(object destination) + { + BindingParameter target = destination as BindingParameter; + if (target == null) + return false; + + if (target.type != type) + return false; + + if (!target.canBeInternal && binding == BindingType.Internal) + return false; + + return true; + } + + public object Copy(object destination) + { + BindingParameter target = destination as BindingParameter; + + BindingParameter copy = new BindingParameter(); + if (target != null) + copy.canBeInternal = target.canBeInternal; + else + copy.canBeInternal = canBeInternal; + + copy.binding = binding; + copy.boolValue = boolValue; + copy.boundsValue = boundsValue; + copy.colorValue = colorValue; + copy.component = component; + copy.floatValue = floatValue; + copy.gameObject = gameObject; + copy.intValue = intValue; + copy.method = method; + copy.qualifiedTypeName = qualifiedTypeName; + copy.rectValue = rectValue; + copy.referenceValue = referenceValue; + copy.stringValue = stringValue; + copy.type = type; + copy.vector2Value = vector2Value; + copy.vector3Value = vector3Value; + copy.vector4Value = vector4Value; + + return copy; + } + + public override string ToString() + { + return type.ToString(); + } + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Core/ActionBinding.cs.meta b/Assets/Plugins/AdvancedInspector/Core/ActionBinding.cs.meta new file mode 100644 index 00000000..1b2c79dc --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/ActionBinding.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3dda590f8ffeb5848b2e6775c1caa63a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Core/ComponentMonoBehaviour.cs b/Assets/Plugins/AdvancedInspector/Core/ComponentMonoBehaviour.cs new file mode 100644 index 00000000..e5d04884 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/ComponentMonoBehaviour.cs @@ -0,0 +1,199 @@ +using UnityEngine; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace AdvancedInspector +{ + /// <summary> + /// ScriptableObject are not serializable within the scope of a GameObject. + /// Therefore, they are improper to prefab, copy and so on. + /// This class' goal is to provide a polymorphic solution and give an easy way of handling up front. + /// + /// Derived from Object; no polymorphism supported. + /// Derived from ScriptableObject; cannot be prefabed, copied, duplicated or instanced. + /// Derived from MonoBehaviour; can only live on a GameObject. + /// + /// A ComponentMonoBehaviour is created from another MonoBehaviour; its parent. + /// A parent can be another ComponentMonoBehaviour. + /// If the parent is destroyed, the subcomponent is destroyed too. + /// If a subcomponent is found without a parent, it's destroyed too. + /// </summary> + [AdvancedInspector] + public abstract class ComponentMonoBehaviour : MonoBehaviour + { + [SerializeField] + private MonoBehaviour owner; + + /// <summary> + /// The owner of a "subcomponent". + /// Use to know if this component lost its parent. + /// If so, the AdvancedInspector will delete any unused component. + /// </summary> + public MonoBehaviour Owner + { + get { return owner; } + set + { + if (value != null) + owner = value; + } + } + + /// <summary> + /// A subcomponent is not visible the normal way in the Inspector. + /// It's shown as being part of another item. + /// </summary> + protected virtual void Reset() + { + hideFlags = HideFlags.HideInInspector; + } + + /// <summary> + /// Called when the inspector is about to destroy this one. + /// Loop in all the internal and destroy sub-components. + /// </summary> + public void Erase() + { + foreach (FieldInfo info in GetFields(GetType(), false)) + { + object value = info.GetValue(this); + + if (value is ComponentMonoBehaviour) + { + ComponentMonoBehaviour component = value as ComponentMonoBehaviour; + + if (component.Owner == Owner) + component.Erase(); + } + } + + DestroyImmediate(this, true); + } + + /// <summary> + /// Instanciate an existing Component on the same owner GameObject + /// </summary> + public ComponentMonoBehaviour Instantiate() + { + return Instantiate(gameObject, Owner); + } + + /// <summary> + /// Instanciate an existing Component on the same owner GameObject but with a new onwer. + /// </summary> + public ComponentMonoBehaviour Instantiate(MonoBehaviour owner) + { + return Instantiate(gameObject, owner); + } + + /// <summary> + /// Instanciate an existing Component on the target GameObject. + /// </summary> + public ComponentMonoBehaviour Instantiate(GameObject go, MonoBehaviour owner) + { + return CopyObject(go, owner, this) as ComponentMonoBehaviour; + } + + private static object CopyObject(GameObject go, MonoBehaviour owner, object original) + { + if (original == null) + return null; + + Type type = original.GetType(); + + if (type == typeof(string)) + + return ((string)original).Clone(); + else if (type.Namespace == "System") + return original; + else if (typeof(IList).IsAssignableFrom(type)) + return CopyList(go, owner, (IList)original); + else if (typeof(ComponentMonoBehaviour).IsAssignableFrom(type) && ((ComponentMonoBehaviour)original).Owner == owner) + return CopyComponent(go, owner, (ComponentMonoBehaviour)original); + else if (typeof(Component).IsAssignableFrom(type)) + return original; + else if (typeof(ScriptableObject).IsAssignableFrom(type)) + return ScriptableObject.Instantiate((ScriptableObject)original); + else if (typeof(UnityEngine.Object).IsAssignableFrom(type)) + return original; + else if (type.IsClass) + return CopyClass(go, owner, original); + else + return original; + } + + private static IList CopyList(GameObject go, MonoBehaviour owner, IList original) + { + Type type = original.GetType(); + IList copy; + + if (type.IsArray) + { + copy = Array.CreateInstance(type.GetElementType(), original.Count); + for (int i = 0; i < original.Count; i++) + copy[i] = CopyObject(go, owner, original[i]); + } + else + { + copy = Activator.CreateInstance(type) as IList; + for (int i = 0; i < original.Count; i++) + copy.Add(CopyObject(go, owner, original[i])); + + } + + return copy; + } + + private static ComponentMonoBehaviour CopyComponent(GameObject go, MonoBehaviour owner, ComponentMonoBehaviour original) + { + Type type = original.GetType(); + ComponentMonoBehaviour copy = go.AddComponent(original.GetType()) as ComponentMonoBehaviour; + + foreach (FieldInfo info in GetFields(type, false)) + { + if (info.IsLiteral) + continue; + + info.SetValue(copy, CopyObject(go, copy, info.GetValue(original))); + } + + copy.Owner = owner; + + return copy; + } + + private static object CopyClass(GameObject go, MonoBehaviour owner, object original) + { + Type type = original.GetType(); + object copy = Activator.CreateInstance(type); + + foreach (FieldInfo info in GetFields(type, false)) + { + if (info.IsLiteral) + continue; + + info.SetValue(copy, CopyObject(go, owner, info.GetValue(original))); + } + + return copy; + } + + private static List<FieldInfo> GetFields(Type type, bool recursive) + { + List<FieldInfo> infos; + + if (recursive) + infos = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).ToList(); + else + infos = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy).ToList(); + + if (type.BaseType != null && type.BaseType != typeof(object)) + infos.AddRange(GetFields(type.BaseType, true)); + + return infos; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Core/ComponentMonoBehaviour.cs.meta b/Assets/Plugins/AdvancedInspector/Core/ComponentMonoBehaviour.cs.meta new file mode 100644 index 00000000..d987b370 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/ComponentMonoBehaviour.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d411934b81db62841acf60342a15b9c3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Core/RangeFloat.cs b/Assets/Plugins/AdvancedInspector/Core/RangeFloat.cs new file mode 100644 index 00000000..f7442db6 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/RangeFloat.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AdvancedInspector +{ + [Serializable] + public struct RangeFloat + { + public float min; + public float max; + + public RangeFloat(float min, float max) + { + this.min = min; + this.max = max; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Core/RangeFloat.cs.meta b/Assets/Plugins/AdvancedInspector/Core/RangeFloat.cs.meta new file mode 100644 index 00000000..a2c19ce3 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/RangeFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bee2349f549bbc341bd8f823cb45ccbf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Core/RangeInt.cs b/Assets/Plugins/AdvancedInspector/Core/RangeInt.cs new file mode 100644 index 00000000..bfe55c58 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/RangeInt.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AdvancedInspector +{ + [Serializable] + public struct RangeInt + { + public int min; + public int max; + + public RangeInt(int min, int max) + { + this.min = min; + this.max = max; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Core/RangeInt.cs.meta b/Assets/Plugins/AdvancedInspector/Core/RangeInt.cs.meta new file mode 100644 index 00000000..3b73338c --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/RangeInt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6c92ce2aa7de2a7438784b0cc719f9ac +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Core/UDictionary.cs b/Assets/Plugins/AdvancedInspector/Core/UDictionary.cs new file mode 100644 index 00000000..5322154f --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/UDictionary.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.InteropServices; +using System.Runtime.Serialization; +using System.Text; + +using UnityEngine; + +namespace AdvancedInspector +{ + [Serializable] + [ComVisible(false)] + [DebuggerDisplay("Count = {Count}")] + public class UDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable, ISerializable, IDeserializationCallback, ISerializationCallbackReceiver + { + [SerializeField] + private List<TKey> keys = new List<TKey>(); + + [SerializeField] + private List<TValue> values = new List<TValue>(); + + [NonSerialized] + private Dictionary<TKey, TValue> dictionary = new Dictionary<TKey, TValue>(); + + #region Implementation of ISerializationCallbackReceiver + public void OnAfterDeserialize() + { + dictionary.Clear(); + for (int i = 0; i < keys.Count; i++) + if (keys[i] != null && (!(keys[i] is UnityEngine.Object) || ((UnityEngine.Object)(object)keys[i]))) + dictionary.Add(keys[i], values[i]); + } + + public void OnBeforeSerialize() + { + keys.Clear(); + values.Clear(); + foreach (KeyValuePair<TKey, TValue> pair in dictionary) + { + if (pair.Key == null || (pair.Key is UnityEngine.Object && !((UnityEngine.Object)(object)pair.Key))) + continue; + + keys.Add(pair.Key); + values.Add(pair.Value); + } + } + #endregion + + #region Implementation of ISerializable + public void GetObjectData(SerializationInfo info, StreamingContext context) + { + dictionary.GetObjectData(info, context); + } + #endregion + + #region Implementation of IDeserializationCallback + public void OnDeserialization(object sender) + { + dictionary.OnDeserialization(sender); + } + #endregion + + #region Implementation IDictionary + public bool IsFixedSize + { + get { return false; } + } + + public ICollection<TKey> Keys + { + get { return dictionary.Keys; } + } + + ICollection IDictionary.Keys + { + get { return dictionary.Keys; } + } + + public ICollection<TValue> Values + { + get { return dictionary.Values; } + } + + ICollection IDictionary.Values + { + get { return dictionary.Values; } + } + + public TValue this[TKey key] + { + get { return dictionary[key]; } + set { dictionary[key] = value; } + } + + object IDictionary.this[object key] + { + get + { + if (!(key is TKey)) + return null; + + return dictionary[(TKey)key]; + } + set + { + if (!(key is TKey)) + return; + + if (!(value is TValue) && value != null) + return; + + dictionary[(TKey)key] = (TValue)value; + } + } + + public void Add(TKey key, TValue value) + { + dictionary.Add(key, value); + } + + void IDictionary.Add(object key, object value) + { + if (!(key is TKey)) + return; + + if (!(value is TValue) && value != null) + return; + + dictionary.Add((TKey)key, (TValue)value); + } + + public bool ContainsKey(TKey key) + { + return dictionary.ContainsKey(key); + } + + bool IDictionary.Contains(object key) + { + if (!(key is TKey)) + return false; + + return dictionary.ContainsKey((TKey)key); + } + + public bool Remove(TKey key) + { + return dictionary.Remove(key); + } + + void IDictionary.Remove(object key) + { + if (!(key is TKey)) + return; + + dictionary.Remove((TKey)key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + return dictionary.TryGetValue(key, out value); + } + + IDictionaryEnumerator IDictionary.GetEnumerator() + { + return ((IDictionary)dictionary).GetEnumerator(); + } + #endregion + + #region Implementation ICollection + public int Count + { + get { return dictionary.Count; } + } + + public bool IsReadOnly + { + get { return false; } + } + + public bool IsSynchronized + { + get { return false; } + } + + public object SyncRoot + { + get { return null; } + } + + public void Add(KeyValuePair<TKey, TValue> item) + { + dictionary.Add(item.Key, item.Value); + } + + public void Clear() + { + dictionary.Clear(); + } + + public bool Contains(KeyValuePair<TKey, TValue> item) + { + return dictionary.ContainsKey(item.Key) && dictionary[item.Key].Equals(item.Value); + } + + void ICollection.CopyTo(Array array, int index) { } + + void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) { } + + public bool Remove(KeyValuePair<TKey, TValue> item) + { + return dictionary.Remove(item.Key); + } + #endregion + + #region Implementation of IEnumerable + public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() + { + return dictionary.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return dictionary.GetEnumerator(); + } + #endregion + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Core/UDictionary.cs.meta b/Assets/Plugins/AdvancedInspector/Core/UDictionary.cs.meta new file mode 100644 index 00000000..f39539f9 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Core/UDictionary.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9e2fe3e177768eb42ac8308f4f3e3c6a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Event.meta b/Assets/Plugins/AdvancedInspector/Event.meta new file mode 100644 index 00000000..135b7127 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Event.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: cfb5bf0cc1004984c86ae71dfdef427c +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/AdvancedInspector/Event/EventHandlers.cs b/Assets/Plugins/AdvancedInspector/Event/EventHandlers.cs new file mode 100644 index 00000000..9c0418d4 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Event/EventHandlers.cs @@ -0,0 +1,22 @@ +using UnityEngine; + +namespace AdvancedInspector +{ + public delegate void GenericEventHandler(); + + public delegate void SenderEventHandler(object sender); + + public delegate void BoolEventHandler(object sender, bool value); + public delegate void IntEventHandler(object sender, int value); + public delegate void FloatEventHandler(object sender, float value); + public delegate void StringEventHandler(object sender, string value); + public delegate void ObjectEventHandler(object sender, object value); + public delegate void Vector2EventHandler(object sender, Vector2 value); + public delegate void Vector3EventHandler(object sender, Vector3 value); + public delegate void Vector4EventHandler(object sender, Vector4 value); + + public delegate void CollisionEventHandler(object sender, Collision value); + public delegate void ColliderEventHandler(object sender, Collider value); + + public delegate void ActionEventHandler(object sender, object[] args); +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Event/EventHandlers.cs.meta b/Assets/Plugins/AdvancedInspector/Event/EventHandlers.cs.meta new file mode 100644 index 00000000..4c6c1268 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Event/EventHandlers.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ada727c2815079443b04c23643983797 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Interface.meta b/Assets/Plugins/AdvancedInspector/Interface.meta new file mode 100644 index 00000000..16d6ab7f --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: f1b6b242a5028dc4b8f87041356c7c93 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/AdvancedInspector/Interface/ICopiable.cs b/Assets/Plugins/AdvancedInspector/Interface/ICopiable.cs new file mode 100644 index 00000000..8498e056 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/ICopiable.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AdvancedInspector +{ + /// <summary> + /// Give an object the power to detect if it can be clone to the target location. + /// </summary> + public interface ICopiable + { + /// <summary> + /// Should return true if the object can be copied to replace the object destination. + /// </summary> + bool Copiable(object destination); + } +} diff --git a/Assets/Plugins/AdvancedInspector/Interface/ICopiable.cs.meta b/Assets/Plugins/AdvancedInspector/Interface/ICopiable.cs.meta new file mode 100644 index 00000000..fe1413d4 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/ICopiable.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5be419eaa25267d4abffe1323b92fdba +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Interface/ICopy.cs b/Assets/Plugins/AdvancedInspector/Interface/ICopy.cs new file mode 100644 index 00000000..d3584276 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/ICopy.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AdvancedInspector +{ + /// <summary> + /// Give an object the power to handle it's own copying over an target destination. + /// </summary> + public interface ICopy + { + /// <summary> + /// Should return a copy of itself. The overriden destination object is passed in case important fields are not to be replaced. + /// </summary> + object Copy(object destination); + } +} diff --git a/Assets/Plugins/AdvancedInspector/Interface/ICopy.cs.meta b/Assets/Plugins/AdvancedInspector/Interface/ICopy.cs.meta new file mode 100644 index 00000000..e96268ea --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/ICopy.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c3c8bf575d7676a4bb245bda97724449 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Interface/IDataChanged.cs b/Assets/Plugins/AdvancedInspector/Interface/IDataChanged.cs new file mode 100644 index 00000000..65e93a85 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IDataChanged.cs @@ -0,0 +1,24 @@ +using UnityEngine; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + /// <summary> + /// Define an interface called when the Inspector has performed changes. + /// The event works the other way around, as a way to notify the Inspector something changed and needs to be refreshed. + /// </summary> + public interface IDataChanged + { + /// <summary> + /// Fired when the Inspector changed. + /// </summary> + void DataChanged(); + + /// <summary> + /// Should be fired internal by the object when the fields structure changed. + /// Ex.: Added an object to a list. + /// </summary> + event GenericEventHandler OnDataChanged; + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Interface/IDataChanged.cs.meta b/Assets/Plugins/AdvancedInspector/Interface/IDataChanged.cs.meta new file mode 100644 index 00000000..957af94f --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IDataChanged.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d075315f0f1460743ac06aafae48b280 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Interface/IInspectorRunning.cs b/Assets/Plugins/AdvancedInspector/Interface/IInspectorRunning.cs new file mode 100644 index 00000000..c2038537 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IInspectorRunning.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AdvancedInspector +{ + /// <summary> + /// When implementing this, gives the object ability to draw the header and footer of the Inspector's space. + /// </summary> + public interface IInspectorRunning + { + /// <summary> + /// Draw at the top of the inspector, in this order; + /// - This + /// - Class Helpbox + /// - Tabs + /// rest of the fields + /// </summary> + void OnHeaderGUI(); + + /// <summary> + /// Draw at the bottom of the inspector, in this order; + /// - Helpbox + /// - This + /// </summary> + void OnFooterGUI(); + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Interface/IInspectorRunning.cs.meta b/Assets/Plugins/AdvancedInspector/Interface/IInspectorRunning.cs.meta new file mode 100644 index 00000000..ad85b3be --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IInspectorRunning.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 94767ceadd7c79e4da722e9aa451f87e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Interface/IListAttribute.cs b/Assets/Plugins/AdvancedInspector/Interface/IListAttribute.cs new file mode 100644 index 00000000..2f020402 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IListAttribute.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AdvancedInspector +{ + /// <summary> + /// Define an attribute that can be passed down to list/array elements. + /// </summary> + public interface IListAttribute { } +} diff --git a/Assets/Plugins/AdvancedInspector/Interface/IListAttribute.cs.meta b/Assets/Plugins/AdvancedInspector/Interface/IListAttribute.cs.meta new file mode 100644 index 00000000..d180ca1e --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IListAttribute.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fec0fc7a00e58804ab5c94aa860790b7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Interface/IPreview.cs b/Assets/Plugins/AdvancedInspector/Interface/IPreview.cs new file mode 100644 index 00000000..9dcf487c --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IPreview.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using UnityEngine; + +namespace AdvancedInspector +{ + /// <summary> + /// Implements the method required to display an inspector preview. + /// </summary> + public interface IPreview + { + /// <summary> + /// This should return instance(s) of the following type; + /// GameObject + /// Mesh + /// Material + /// Texture + /// Cubemap + /// If return null or empty array, preview is turned off. + /// </summary> + UnityEngine.Object[] Preview { get; } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Interface/IPreview.cs.meta b/Assets/Plugins/AdvancedInspector/Interface/IPreview.cs.meta new file mode 100644 index 00000000..841448df --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IPreview.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bea75a5ed3255024b904a3ebfddcb15b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Interface/IRuntimeAttribute.cs b/Assets/Plugins/AdvancedInspector/Interface/IRuntimeAttribute.cs new file mode 100644 index 00000000..10710819 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IRuntimeAttribute.cs @@ -0,0 +1,44 @@ +using UnityEngine; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +namespace AdvancedInspector +{ + /// <summary> + /// Define an attribute that stores a method name + /// Which should be turned into a delegate at runtime. + /// </summary> + public interface IRuntimeAttribute<T> : IRuntimeAttribute + { + /// <summary> + /// Invoke the internal delegates and returns the requested values. + /// T should be the same type as the Delegate return type. + /// </summary> + T Invoke(int index, object instance, object value); + } + + public interface IRuntimeAttribute + { + /// <summary> + /// Name of the MethodInfo to retrieve at runtime. + /// </summary> + string MethodName { get; } + + /// <summary> + /// Prototype template of the delegate to create + /// </summary> + Type Template { get; } + + /// <summary> + /// Prototype template for static external delegate + /// </summary> + Type TemplateStatic { get; } + + /// <summary> + /// List of delegates to invoke. + /// </summary> + List<Delegate> Delegates { get; set; } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/AdvancedInspector/Interface/IRuntimeAttribute.cs.meta b/Assets/Plugins/AdvancedInspector/Interface/IRuntimeAttribute.cs.meta new file mode 100644 index 00000000..54a67e7e --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Interface/IRuntimeAttribute.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a59d020caab68e44bbc71d13e9f12fc1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/AdvancedInspector/Utility.meta b/Assets/Plugins/AdvancedInspector/Utility.meta new file mode 100644 index 00000000..d7968f20 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Utility.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 24d4e9172de017a4b805b56622be50d7 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/AdvancedInspector/Utility/TypeUtility.cs b/Assets/Plugins/AdvancedInspector/Utility/TypeUtility.cs new file mode 100644 index 00000000..a445b8e9 --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Utility/TypeUtility.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace AdvancedInspector +{ + public class TypeUtility + { + public static Type GetTypeByName(string name) + { + foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + foreach (Type type in assembly.GetTypes()) + { + if (type.Name == name) + return type; + } + } + + return null; + } + } +} diff --git a/Assets/Plugins/AdvancedInspector/Utility/TypeUtility.cs.meta b/Assets/Plugins/AdvancedInspector/Utility/TypeUtility.cs.meta new file mode 100644 index 00000000..dd719c2c --- /dev/null +++ b/Assets/Plugins/AdvancedInspector/Utility/TypeUtility.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2053e8109e8ace34897756007aa622d2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor.meta b/Assets/Plugins/Editor.meta new file mode 100644 index 00000000..850194e2 --- /dev/null +++ b/Assets/Plugins/Editor.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 6a58e207379bbc441bd2ef8d321d7707 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector.meta b/Assets/Plugins/Editor/AdvancedInspector.meta new file mode 100644 index 00000000..95d6ec65 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 5fc2dde4e518f4743be154c3078ef7c9 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.XML b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.XML new file mode 100644 index 00000000..a2386fed --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.XML @@ -0,0 +1,1630 @@ +<?xml version="1.0"?> +<doc> + <assembly> + <name>AdvancedInspector</name> + </assembly> + <members> + <member name="T:AdvancedInspector.AdvancedInspectorControl"> + <summary> + A collection of static method made to handle the drawing of the Advanced Inspector. + In most cases, you won't have to deal with this class. + </summary> + </member> + <member name="T:AdvancedInspector.IModal"> + <summary> + This EditorWindow can recieve and send Toolbox inputs. + </summary> + </member> + <member name="M:AdvancedInspector.IModal.ModalRequest(System.Boolean)"> + <summary> + Called when the Toolbox shortcut is pressed. + The implementation should call CreateToolbox if the condition are right. + </summary> + </member> + <member name="M:AdvancedInspector.IModal.ModalClosed(AdvancedInspector.ModalWindow)"> + <summary> + Called when the associated toolbox is closed. + Only called when Ok/Cancel or Enter/Escape is pressed. + There's no reliable way of trapping the "click outside the popup" event. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.ModalRequest(System.Boolean)"> + <summary> + IModal Implementation. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.ModalClosed(AdvancedInspector.ModalWindow)"> + <summary> + IModal Implementation. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.Inspect(AdvancedInspector.InspectorEditor,System.Collections.Generic.List{AdvancedInspector.InspectorField},System.Boolean,System.Boolean)"> + <summary> + Called by an Editor to have a collection of InspectorField to be displayed. + Uniformized entry point of inspector drawing. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.Inspect(AdvancedInspector.InspectorEditor,System.Collections.Generic.List{AdvancedInspector.InspectorField},System.Boolean,System.Boolean,System.Boolean)"> + <summary> + Called by an Editor to have a collection of InspectorField to be displayed. + Uniformized entry point of inspector drawing. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.Inspect(AdvancedInspector.InspectorEditor,System.Collections.Generic.List{AdvancedInspector.InspectorField},System.Boolean,System.Boolean,System.Boolean,Separator)"> + <summary> + Called by an Editor to have a collection of InspectorField to be displayed. + Uniformized entry point of inspector drawing. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.Draw(AdvancedInspector.InspectorEditor,AdvancedInspector.InspectorField,System.Collections.Generic.List{AdvancedInspector.InspectorField},System.Boolean,System.Boolean,System.Boolean)"> + <summary> + Entry point of the inspection of a Property based editor. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.InitList(AdvancedInspector.InspectorField)"> + <summary> + Unity doesn't always properly init it's array/list if a serialization reload didn't occur. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawExpander(AdvancedInspector.InspectorField,AdvancedInspector.FieldEditor,System.Boolean)"> + <summary> + Draw the arrow icon that allow to browse sub-object property. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawIndexedControl(AdvancedInspector.InspectorField)"> + <summary> + Draw the control of an sortable list. + Return true if a list has been modified and requires a redraw. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawKeyedControl(AdvancedInspector.InspectorField)"> + <summary> + Draw the - button for a Dictionary + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawRestricted(AdvancedInspector.InspectorEditor,AdvancedInspector.InspectorField,System.Collections.Generic.IList{AdvancedInspector.DescriptorPair},UnityEngine.GUIStyle)"> + <summary> + Draw the "Restricted" enum, which is a runtime list provide by a method. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawDerived(AdvancedInspector.InspectorEditor,AdvancedInspector.InspectorField)"> + <summary> + Draw the +/- icon to control the creation and deletion of user created object. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawList(AdvancedInspector.InspectorEditor,AdvancedInspector.InspectorField)"> + <summary> + Draw the + icon of a List + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawDictionary(AdvancedInspector.InspectorEditor,AdvancedInspector.InspectorField)"> + <summary> + Draw the + icon of a Dictionary + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawLabel(AdvancedInspector.FieldEditor,AdvancedInspector.InspectorField,System.Boolean)"> + <summary> + Draw the left side of a field, the label. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.GetWidth(AdvancedInspector.InspectorField)"> + <summary> + Width of the label part. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawHelp(AdvancedInspector.InspectorField,System.Boolean)"> + <summary> + Draw the help box bellow the field. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.DrawClassHelp(System.Object[],System.Boolean)"> + <summary> + Help box at the top or bottom of the whole inspector. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.ParseRuntimeAttributes(AdvancedInspector.IRuntimeAttribute,System.Type,System.Object[])"> + <summary> + This method is invoked to build a list of proper delegate to invoke. + </summary> + </member> + <member name="M:AdvancedInspector.AdvancedInspectorControl.GetDerived(System.Type)"> + <summary> + Get the list of valid derivaton from a specific type. + Used to create derived object, should always be from ComponentMonoBehaviour but is not enforced. + </summary> + </member> + <member name="P:AdvancedInspector.AdvancedInspectorControl.BoxStyle"> + <summary> + Group box style + </summary> + </member> + <member name="P:AdvancedInspector.AdvancedInspectorControl.Suspended"> + <summary> + When complex operation are performed, the Inspector blocks repaint. + </summary> + </member> + <member name="P:AdvancedInspector.AdvancedInspectorControl.Level"> + <summary> + Current complexity level. + </summary> + </member> + <member name="P:AdvancedInspector.AdvancedInspectorControl.Sorting"> + <summary> + How the fields are sorted. + </summary> + </member> + <member name="E:AdvancedInspector.AdvancedInspectorControl.SortingChanged"> + <summary> + Raised if the inspector needs a redraw. + </summary> + </member> + <member name="P:AdvancedInspector.AdvancedInspectorControl.Editor"> + <summary> + Used for internal callback from a modal windows. + </summary> + </member> + <member name="P:AdvancedInspector.AdvancedInspectorControl.Field"> + <summary> + Used for internal callback from a modal windows. + </summary> + </member> + <member name="T:AdvancedInspector.AdvancedInspectorControl.InspectorSorting"> + <summary> + Field sorting enum. + </summary> + </member> + <member name="F:AdvancedInspector.AdvancedInspectorControl.InspectorSorting.None"> + <summary> + No sorting, using the order found in code. + </summary> + </member> + <member name="F:AdvancedInspector.AdvancedInspectorControl.InspectorSorting.Alpha"> + <summary> + Alphabethic sorting A, B, C... + </summary> + </member> + <member name="F:AdvancedInspector.AdvancedInspectorControl.InspectorSorting.AntiAlpha"> + <summary> + Anti-alphabethic sorting, C, B, A... + </summary> + </member> + <member name="T:AdvancedInspector.FieldEditor"> + <summary> + When a specific type is encounter by the Inspector, we check if someone defined an field editor for it. + When it occurs, all the field drawing is left to the custom editor. + </summary> + </member> + <member name="F:AdvancedInspector.FieldEditor.MIN_FIELD_HEIGHT"> + <summary> + Minimum field height + </summary> + </member> + <member name="F:AdvancedInspector.FieldEditor.BUTTON_HEIGHT"> + <summary> + Button Height + </summary> + </member> + <member name="F:AdvancedInspector.FieldEditor.VECTOR_FIELD_WIDTH"> + <summary> + Standard float-in-vector label width + </summary> + </member> + <member name="M:AdvancedInspector.FieldEditor.Draw(AdvancedInspector.InspectorField,UnityEngine.GUIStyle)"> + <summary> + The draw call from the Inspector. + </summary> + </member> + <member name="M:AdvancedInspector.FieldEditor.OnLabelDraw(AdvancedInspector.InspectorField,UnityEngine.Rect)"> + <summary> + Called after the label is drawn. + Useful to add dragging modifier. + </summary> + </member> + <member name="M:AdvancedInspector.FieldEditor.OnLabelClick(AdvancedInspector.InspectorField)"> + <summary> + Event raised when someone click a label. + </summary> + </member> + <member name="M:AdvancedInspector.FieldEditor.OnLabelDoubleClick(AdvancedInspector.InspectorField)"> + <summary> + Event raised when someone double click a label. + </summary> + </member> + <member name="M:AdvancedInspector.FieldEditor.OnLabelDragged(AdvancedInspector.InspectorField)"> + <summary> + Fired when someone click and drag the label with modified key (control/shift/alt) pressed. + A normal drag performs a copy/paste. + </summary> + </member> + <member name="M:AdvancedInspector.FieldEditor.OnContextualClick(AdvancedInspector.InspectorField,UnityEditor.GenericMenu)"> + <summary> + Event raised when someone right-click a label. + The GenenicMenu is empty and can add new items in it. + </summary> + </member> + <member name="M:AdvancedInspector.FieldEditor.GetValue(AdvancedInspector.InspectorField)"> + <summary> + Get the value of a field. + Flag "Show Mixed Value" automaticly and return null if a multi-selection has different values. + </summary> + </member> + <member name="P:AdvancedInspector.FieldEditor.Expandable"> + <summary> + Override if you want to prevent a type from being expandable at any time. + Override the Expandable attributes. + </summary> + </member> + <member name="P:AdvancedInspector.FieldEditor.EditDerived"> + <summary> + If true and no fieldeditor is found for a specific type, this fieldeditor is used for the derived type. + </summary> + </member> + <member name="P:AdvancedInspector.FieldEditor.EditedTypes"> + <summary> + List of type this FieldEditor edit. + </summary> + </member> + <member name="T:AdvancedInspector.InspectorEditor"> + <summary> + Base class of BehaviourEditor, ScriptableEditor and ExternalEditor. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.HasPreviewGUI"> + <summary> + Preview is handled internally and is turned on and off using IPreview interface. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorEditor.parent"> + <summary> + In case of value type, we need to know the parent. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorEditor.fields"> + <summary> + List of fields held by this inspector. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorEditor.refresh"> + <summary> + When a value changed internally, this forces the fields to be refreshed. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.OnEnable"> + <summary> + Unity's OnEnable. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.OnDisable"> + <summary> + Unity's OnDisable + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.StartPicking(System.Action{UnityEngine.GameObject,System.Object},System.Object)"> + <summary> + Start the Scene View picking tool. + Type can define the component we seek on a GameObject. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.StopPicking"> + <summary> + Stop the picking tool before it has resolved. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.OnPreviewGUI(UnityEngine.Rect,UnityEngine.GUIStyle)"> + <summary> + Preview Draw + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.OnSceneGUI"> + <summary> + Override this method if you want to draw on the scene view. + Don't forget to call the base. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.OnPreviewSettings"> + <summary> + Preview Settings + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.DataChanged"> + <summary> + Data Changed, repaint. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.UseDefaultMargins"> + <summary> + Unity's Default Margins. False if running in Advanced Inspector. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.OnInspectorGUI"> + <summary> + Default Inspector entry point. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.DrawAdvancedInspector"> + <summary> + Similar to "DrawDefaultInspector", except this is the Advanced one. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorEditor.RefreshFields"> + <summary> + Force this field to rebuild the list of its children. + If you implement an editor specific to a type, you should only need to override this method. + Consider clearing existing fields before adding new one. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorEditor.Picking"> + <summary> + Is the Inspector currently in picking mode? + </summary> + </member> + <member name="P:AdvancedInspector.InspectorEditor.Advanced"> + <summary> + Return true if this editor is using advanced features. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorEditor.Instances"> + <summary> + We use our own targets list because we can draw object not deriving from UnityEngine.Object. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorEditor.Fields"> + <summary> + List of fields held by this inspector. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorEditor.Expandable"> + <summary> + Override this if you implement your own inspector and doesn't want it to be expandable. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorEditor.TestForDefaultInspector"> + <summary> + If true, will test if the type of in the inspector object has "AdvancedInspector" attributes. + Default; false; + </summary> + </member> + <member name="T:AdvancedInspector.BehaviourEditor"> + <summary> + Behaviour Editor is the entry point for all MonoBehaviour in Advanced Inspector. + </summary> + </member> + <member name="M:AdvancedInspector.BehaviourEditor.OnEnable"> + <summary> + Unity's OnEnable. + </summary> + </member> + <member name="P:AdvancedInspector.BehaviourEditor.TestForDefaultInspector"> + <summary> + Should we check for the [AdvancedInspectorAttribute]? + </summary> + </member> + <member name="T:AdvancedInspector.ExternalEditor"> + <summary> + Similar to a standard PropertyInspector, but can be called from outside the scope of a Inspector. + Useful to build your own EditorWindow with an integrated inspector. + Call the method Draw with a Rect of the region to draw on. + </summary> + </member> + <member name="T:AdvancedInspector.IControl"> + <summary> + Define a control that can be drawn in an EditorWindow. + </summary> + </member> + <member name="M:AdvancedInspector.IControl.Draw(UnityEngine.Rect)"> + <summary> + Draw the control. Return if the parent EditorWindow should repaint the window. + </summary> + </member> + <member name="E:AdvancedInspector.IControl.RequestRepaint"> + <summary> + In the event an internal process of the Control want a repaint of the window outside the Drawing scope. + </summary> + </member> + <member name="M:AdvancedInspector.ExternalEditor.Draw(UnityEngine.Rect)"> + <summary> + IControl implementation + </summary> + </member> + <member name="P:AdvancedInspector.ExternalEditor.Expandable"> + <summary> + If false, the Inspector won't draw the expander and won't reserve space on the left of the labels. + </summary> + </member> + <member name="P:AdvancedInspector.ExternalEditor.DraggableSeparator"> + <summary> + Can the separator be dragged around? + </summary> + </member> + <member name="P:AdvancedInspector.ExternalEditor.DivisionSeparator"> + <summary> + Where is the separator? + In PerPixel, the value is in pixel from the top or the left. + Otherwise, it's in %. + </summary> + </member> + <member name="E:AdvancedInspector.ExternalEditor.RequestRepaint"> + <summary> + IControl implementation + </summary> + </member> + <member name="T:AdvancedInspector.ScriptableEditor"> + <summary> + Scriptable Editor is the entry point for all ScriptableObject in Advanced Inspector. + </summary> + </member> + <member name="M:AdvancedInspector.ScriptableEditor.OnEnable"> + <summary> + Unity's OnEnable. + </summary> + </member> + <member name="P:AdvancedInspector.ScriptableEditor.TestForDefaultInspector"> + <summary> + Should we check for the [AdvancedInspectorAttribute]? + </summary> + </member> + <member name="T:AdvancedInspector.InspectorField"> + <summary> + Pooled information about a PropertyInfo and translated for the Inspector. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField)"> + <summary> + This constructor is used as a duplication. + Note that this field is free and not parented to anything. + Use with great care! + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(System.Type,System.Object[],System.Reflection.MemberInfo,System.Attribute[])"> + <summary> + Entry point for a generic manually created field. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,System.Type,System.Object[],System.Reflection.MemberInfo,System.Attribute[])"> + <summary> + Entry point for a generic manually created field. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,System.Int32,UnityEditor.SerializedProperty,System.Attribute[])"> + <summary> + Entry point for a generic indexed serialized created field. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(System.Type,System.Object[],UnityEditor.SerializedProperty,System.Attribute[])"> + <summary> + Entry point for a generic serialized created field. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(System.String)"> + <summary> + Entry point for an empty field with no editor. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.GroupAttribute)"> + <summary> + Entry point of a group. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.ToolbarAttribute)"> + <summary> + Entry point of a toolbar. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,System.Object[],System.Int32,System.Attribute[])"> + <summary> + Entry point for a indexed field. + You should not create this manually. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,System.Object[],System.Object,System.Attribute[])"> + <summary> + Entry point of a Dictionary item. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(System.Type)"> + <summary> + Entry point for a non-member related field. + Useful to draw a single FieldEditor. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,UnityEngine.Object[],System.Object[],UnityEditor.SerializedProperty)"> + <summary> + Script entry point. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(UnityEngine.Object[],System.String)"> + <summary> + Entry point for a Field created from a path and Object ids. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,UnityEngine.Object[],System.Object[],System.Reflection.MethodInfo)"> + <summary> + Entry point for a method field. (Button) + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,UnityEngine.Object[],System.Object[],System.Reflection.MethodInfo,System.Attribute[])"> + <summary> + Entry point for a method field. (Button) + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,UnityEngine.Object[],System.Object[],UnityEngine.Object,System.Reflection.FieldInfo)"> + <summary> + Entry point for a standard field. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,UnityEngine.Object[],System.Object[],UnityEngine.Object,System.Reflection.FieldInfo,System.Boolean)"> + <summary> + Entry point for a standard field. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,UnityEngine.Object[],System.Object[],UnityEngine.Object,System.Reflection.FieldInfo,System.Boolean,System.Attribute[])"> + <summary> + Entry point for a standard field. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,UnityEngine.Object[],System.Object[],UnityEngine.Object,System.Reflection.PropertyInfo)"> + <summary> + Entry point for a standard property. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,UnityEngine.Object[],System.Object[],UnityEngine.Object,System.Reflection.PropertyInfo,System.Boolean)"> + <summary> + Entry point for a standard property. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.#ctor(AdvancedInspector.InspectorField,UnityEngine.Object[],System.Object[],UnityEngine.Object,System.Reflection.PropertyInfo,System.Boolean,System.Attribute[])"> + <summary> + Entry point for a standard property. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.op_Equality(AdvancedInspector.InspectorField,AdvancedInspector.InspectorField)"> + <summary> + Compares if two InspectorField contains the same data. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.op_Inequality(AdvancedInspector.InspectorField,AdvancedInspector.InspectorField)"> + <summary> + Compares if two InspectorField contains the same data. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.Equals(System.Object)"> + <summary> + Compares if two InspectorField contains the same data. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetHashCode"> + <summary> + HashCode + </summary> + <returns></returns> + </member> + <member name="M:AdvancedInspector.InspectorField.CompareTo(System.Object)"> + <summary> + IComparable implementation + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.CompareTo(AdvancedInspector.InspectorField)"> + <summary> + IComparable implementation + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.AddAttribute(System.Attribute)"> + <summary> + Force a new attribute to be added a runtime. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetAttribute``1"> + <summary> + Get an attribute by type that was applied to the original item. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetAttribute(System.Type)"> + <summary> + Get an attribute by type that was applied to the original item. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetAttributes``1"> + <summary> + Get all the attributes by type that were applied to the original item. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetAttributes(System.Type)"> + <summary> + Get all the attributes by type that were applied to the original item. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.HasAttribute``1"> + <summary> + Return true if the memberinfo of this field is sporting that specific attribute type. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.HasAttribute(System.Type)"> + <summary> + Return true if the memberinfo of this field is sporting that specific attribute type. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.Watch"> + <summary> + Add this field to the watch list, which is displayed on the Watch window. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.Select"> + <summary> + Force the selection of the serialized instances of this field. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.Save"> + <summary> + Attempt to save this field value in play mode the next time it is stopped. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.Apply"> + <summary> + Apply this field modification to its prefab parent. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.Revert"> + <summary> + Revert any modification of this field and retreived the original value of its prefab parent. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.RecordObjects(System.String)"> + <summary> + Record the object state for undo purpose. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.Copy"> + <summary> + Copy the current value of this field to the clipboard. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.CanPaste(System.Object)"> + <summary> + Return true if the passed value can be copied over this field. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.Paste"> + <summary> + Paste the clipboard data to this field. + Careful, you should do a type test before. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetValue"> + <summary> + The current value of this field. + If not a field, returns null. + If multi object, return null if all the value aren't the same. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetValue``1"> + <summary> + The current value of this field. + If not a field, returns null. + If multi object, return null if all the value aren't the same. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetValue(System.Object)"> + <summary> + The value of this field, based on a specific object instance. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetValue``1(System.Object)"> + <summary> + The value of this field, based on a specific object instance. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetValues"> + <summary> + Get all instances value. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetValues``1"> + <summary> + Get all instances value. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.ResetToDefault"> + <summary> + Reset this field to its default value. + Object = null + Value Type = default(T) + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.SetValue(System.Object)"> + <summary> + Set the value of this field. + Support undo. When calling this, assume undo will be "Set Value MyField" + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.SetValue(System.Object,System.Object)"> + <summary> + Set the value of this field, based on a specific object instance. + Does not support undo, should be recorded before calling. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.SetDirty"> + <summary> + Flags the related serialized instance as dirty. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.RefreshFields"> + <summary> + Reparse the internal sub-fields of this field. + Useful when a list or an object changed. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.SortFields"> + <summary> + Sort all children fields. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetInfoByPath(UnityEngine.Object,System.String)"> + <summary> + Get a MemberInfo from a serializable path. + The "Path" property from a InspectorField is a valid path. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetValueByPath(UnityEngine.Object,System.String)"> + <summary> + Get a value from a serializable path. + The "Path" property from a InspectorField is a valid path. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.SetValueByPath(UnityEngine.Object,System.String,System.Object)"> + <summary> + Set a value by a serializable path. + The "Path" property from a InspectorField is a valid path. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetIndexedProperties(AdvancedInspector.InspectorField,System.Collections.Generic.List{System.Collections.IList})"> + <summary> + Return a list of indexed field. Work with List and Array. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetKeyedProperties(AdvancedInspector.InspectorField,System.Collections.Generic.List{System.Collections.IDictionary})"> + <summary> + Return a list of keyed field. Work with IDictionary. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetMembers(AdvancedInspector.InspectorField,System.Object[])"> + <summary> + Get fields from an object. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetMembers(AdvancedInspector.InspectorField,System.Object[],System.Boolean)"> + <summary> + Get fields from an object. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorField.GetMembers(AdvancedInspector.InspectorField,System.Object[],System.Boolean,System.Boolean)"> + <summary> + Get fields from an object. Bypass ignore Inspect and Expandable attributes. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Instances"> + <summary> + The object owning this specific field. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.SerializedInstances"> + <summary> + The serialized object owning this specific field. + May not be the same as the instance, or even the currently Selected item in the Inspector. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Prefab"> + <summary> + The prefab parent to this object. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Info"> + <summary> + The member info of this field. + PropertyInfo, FieldInfo or MethodInfo. Otherwise null. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Attributes"> + <summary> + The attributes of this field, manually and by reflection. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.SerializedProperty"> + <summary> + Used only for the Script object reference at the top, or hidden Unity property. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.GameObjects"> + <summary> + Get the parents GameObjects in cases of components. Useful for undoes. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Parent"> + <summary> + The parent field in case of nesting. + Null if directly at the top. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Fields"> + <summary> + Subfields, such as field in an expandable object, or a list. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.InternalFields"> + <summary> + Fields used for edition, are not drawn by the Inspector automaticly. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Depth"> + <summary> + Indentation depth of this field. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.InspectorType"> + <summary> + Is this field a method, field, property or a group? + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Undoable"> + <summary> + External editor are sometimes used to browse non-Unity object. + Sadly, undo only works on valid Unity objects. + Also return false if one of the serializable parent became null or none. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Type"> + <summary> + The type of this field. + In most case, would return the FieldInfo.FieldType or PropertyInfo.PropertyType + In case of a group, it returns null. + If this field is flagged as Runtime-Resolved, it returns the type of the current value. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.BaseType"> + <summary> + In case of a collection, returns the base type. + Ex.: int[] or List(int), base type if int. + In a dictionary, return the value type. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.KeyType"> + <summary> + In case of a dictionary, returns the key type. + Return null otherwise. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Inspect"> + <summary> + The Inspect Attribute that made this field visible. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Editor"> + <summary> + The Override Editor assigned to this field. + No field can be drawn without one. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Restrictor"> + <summary> + A restrictor turns any field into a drop down list of specific choices. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Group"> + <summary> + Is this field part of a group? + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Toolbar"> + <summary> + Is this field part of a toolbar? + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Tab"> + <summary> + Is this field visibility controlled by a tab? + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.SelectedTab"> + <summary> + In cases of tabs, this is the currently selected tab enum value. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Descriptor"> + <summary> + The Descriptor assigned to this field. Name, tooltip, icon, etc. + In case of multi-objects, there is no runtime invokation and the descriptor returned is the one on the member. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Static"> + <summary> + Returns true if the item inspected is static. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.ReadOnly"> + <summary> + Readonly field cannot be edited. + In case of multi-objects, if any is readonly, all are. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Animated"> + <summary> + Is this field animated. Only works for fields, not property. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Help"> + <summary> + The Help data being drawn after the field. + Does not work in multi-object edition. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Bypass"> + <summary> + This field is a bypass field, and sub-field automaticly recieve that flag. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Expandable"> + <summary> + Can this field be expanded? + It display the arrow button. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Expanded"> + <summary> + Is this field open and displaying internal fields? + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Erased"> + <summary> + Was this field erased? + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.DisplayAsParent"> + <summary> + Is this object display as being part of the parent? + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.CreateDerived"> + <summary> + Can this object field display the "+" sign to create a derived object from the base type? + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Name"> + <summary> + Name of the label of that field. + Can be modified by Descriptor. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.FieldColor"> + <summary> + The color of the editable field. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.BackgroundColor"> + <summary> + The color of the background (ex.: Expandable box) + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Priority"> + <summary> + Priority of a field, used when sorting. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Order"> + <summary> + The order at which this field was found in the code. + If an indexed field, return the index. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Label"> + <summary> + If false, this field does not draw its label. + Useful for toolbar. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Style"> + <summary> + The specific style this field is draw with. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Path"> + <summary> + Internal path to this specific field. + Used to keep persistant data across selection. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Hidden"> + <summary> + Many thing can prevent a field from being drawn. Ex.: InspectAttribute can hide it. + If internal data from Unity return an exception on read, we skip it. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Editable"> + <summary> + Return false is any of the serialized parent have the hide flag "Not Editable". + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Modified"> + <summary> + Return true if the item is different from it's prefab parent. + Always return false if it's a non-value type and not a ref (UnityEngine.Object). + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Mixed"> + <summary> + Return true when editing multiple object that doesn't have the same value. + Always return true if they are objects and not the same instance. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Similar"> + <summary> + Return true if all instances are of the same type. + Which mean they are expandable even in multi-objects edition + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Index"> + <summary> + Index of the field in a list or array. + Return -1 if not part of a collection. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.IsList"> + <summary> + Is this a collection? (array or list) + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Key"> + <summary> + When in a dictionary, the key of this value. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.IsDictionary"> + <summary> + Is this a dictionary? (UDictionary) + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.Count"> + <summary> + Returns the current number of children. + In case of list, returns the number of items in it. + In case of multiples list, return -1 if all list doesn't have the same number of items. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorField.OverloadToString"> + <summary> + Test if the current type overload ToString properly. + </summary> + </member> + <member name="T:AdvancedInspector.InspectorType"> + <summary> + Type of InspectorField. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorType.None"> + <summary> + Empty unset field + </summary> + </member> + <member name="F:AdvancedInspector.InspectorType.Field"> + <summary> + Field containing a FieldInfo + </summary> + </member> + <member name="F:AdvancedInspector.InspectorType.Property"> + <summary> + Field containing a PropertyInfo + </summary> + </member> + <member name="F:AdvancedInspector.InspectorType.Method"> + <summary> + Field containing a MethodInfo + </summary> + </member> + <member name="F:AdvancedInspector.InspectorType.Serialized"> + <summary> + The InspectorField is only a wrapper around a SerializedProperty object. + To use in case of hidden property in the Unity API. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorType.Group"> + <summary> + Field that is a group of other field. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorType.Toolbar"> + <summary> + Field that is drawn as a toolbar. (horizontal group) + </summary> + </member> + <member name="F:AdvancedInspector.InspectorType.Unlinked"> + <summary> + Unlinked field just stores a value internally and is not bound to an object. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorType.Script"> + <summary> + The top field, the reference towards the original script. + </summary> + </member> + <member name="T:AdvancedInspector.InspectorPreferences"> + <summary> + Handles the Advanced Inspector preferences. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorPreferences.IsDragControl(AdvancedInspector.InspectorPreferences.InspectorDragControl)"> + <summary> + Returns true if the control is valid in the current Event context. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorPreferences.IsControl(AdvancedInspector.InspectorPreferences.InspectorModifierControl)"> + <summary> + Returns true if the control is valid in the current Event context. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorPreferences.Style"> + <summary> + The style collection used for the different element. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorPreferences.InspectDefaultItems"> + <summary> + If true, all classes that do not have a Custom Editor are drawn by Advanced Inspector. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorPreferences.ValueScroll"> + <summary> + The control for scrolling numbers. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorPreferences.CopyPaste"> + <summary> + The control to copy-paste by drag. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorPreferences.MassExpand"> + <summary> + The control modifier used when clicking on an expansion arrow. Expand/Collapse sub-nodes. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorPreferences.Contextual"> + <summary> + Usually to open the contextual menu, you do Right-Click. + In some cases, people may not have access to a proper right-click, so they can do CTRL+Click for example. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorPreferences.ExtraIndentation"> + <summary> + Extra indentation applied to boxes. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorPreferences.LargeCollection"> + <summary> + The maximum number of displayed item in a collection. Trigger the large collection arrow display beyond that. + </summary> + </member> + <member name="T:AdvancedInspector.InspectorPreferences.InspectorDragControl"> + <summary> + The accepted control that involves dragging. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorPreferences.InspectorDragControl.None"> + <summary> + The control is turned off. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorPreferences.InspectorDragControl.Drag"> + <summary> + Single drag. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorPreferences.InspectorDragControl.AltDrag"> + <summary> + Alt+Drag + </summary> + </member> + <member name="F:AdvancedInspector.InspectorPreferences.InspectorDragControl.ControlDrag"> + <summary> + Control+Drag + </summary> + </member> + <member name="F:AdvancedInspector.InspectorPreferences.InspectorDragControl.ShiftDrag"> + <summary> + Shift+Drag + </summary> + </member> + <member name="T:AdvancedInspector.InspectorPreferences.InspectorModifierControl"> + <summary> + The modifier keys involded in non-dragging action. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorPreferences.InspectorModifierControl.Alt"> + <summary> + Alt Key + </summary> + </member> + <member name="F:AdvancedInspector.InspectorPreferences.InspectorModifierControl.Control"> + <summary> + Control Key + </summary> + </member> + <member name="F:AdvancedInspector.InspectorPreferences.InspectorModifierControl.Shift"> + <summary> + Shift Key + </summary> + </member> + <member name="T:AdvancedInspector.InspectorPreview"> + <summary> + This class handles the rendering and input of the Preview zone. + </summary> + </member> + <member name="P:AdvancedInspector.InspectorPreview.Targets"> + <summary> + Object to be previewed + Supported type; + GameObject + Mesh + Material + Texture + </summary> + </member> + <member name="T:AdvancedInspector.InspectorStyle"> + <summary> + The different internal style. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorStyle.Empty"> + <summary> + No boxes, no nothing. Clean, similar to Unity default. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorStyle.Round"> + <summary> + Round boxes. + </summary> + </member> + <member name="F:AdvancedInspector.InspectorStyle.Flat"> + <summary> + Unity flat style + </summary> + </member> + <member name="T:AdvancedInspector.InspectorWrapper"> + <summary> + A wrapper recongnized by the internal inspector so that non-UnityEngine.Object can be inspected. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorWrapper.Select(System.Object)"> + <summary> + Force Unity's "Selection" to use a non-unity object. + </summary> + </member> + <member name="M:AdvancedInspector.InspectorWrapper.IsSelected(System.Object)"> + <summary> + Is this object selected by Unity's Selection? + </summary> + </member> + <member name="M:AdvancedInspector.InspectorWrapper.GetSelection``1"> + <summary> + Get currenty Unity's Selection + </summary> + </member> + <member name="P:AdvancedInspector.InspectorWrapper.Tag"> + <summary> + Object to Inspector + </summary> + </member> + <member name="T:Clipboard"> + <summary> + A copy/paste buffer. + Does not use the System buffer, as it's limited to a string and Unity does not provide a uniformed string serialization. + </summary> + </member> + <member name="M:Clipboard.CreateInstance(System.Type)"> + <summary> + Create an instance of type + Works with values, list, array, scriptableObject, string + Components are ignored. + </summary> + </member> + <member name="M:Clipboard.CreateInstance(UnityEngine.MonoBehaviour,System.Type)"> + <summary> + Create an instance of type + Works with values, list, array, scriptableObject, string + Components are ignored. + + The owner MonoBeahviour is used in case of the creation of a ComponentMonoBehaviour for its internal binding. + </summary> + </member> + <member name="M:Clipboard.Copy(System.Object)"> + <summary> + Perform a deep copy if an object. + Does not perform copies of Components or GameObject + Values are returned as is (ex.: 14) + strings are cloned. + List/Array are enumerated and copied. + Everything else is deep copied by fields. + </summary> + </member> + <member name="M:Clipboard.TryConvertion(System.Type,System.Object@)"> + <summary> + Test if the current clipboard data can be converted into a specific type. + Ex.: int to string + </summary> + </member> + <member name="M:Clipboard.TryConvertion``1(``0@)"> + <summary> + Test if the current clipboard data can be converted into a specific type. + Ex.: int to string + </summary> + </member> + <member name="M:Clipboard.CanConvert(System.Type,System.Object)"> + <summary> + Return true if an object is convertable to a type. + </summary> + </member> + <member name="P:Clipboard.Data"> + <summary> + In case of any normal object, returns deep copy of that object. + In case of a Component, returns the original so you can apply it on a GameObject yourself (sorry) + In case of a UnityEngine.Object, create a new one and perforce a Serialization Copy. + </summary> + </member> + <member name="P:Clipboard.Type"> + <summary> + Type of the current data in the clipboard. + </summary> + </member> + <member name="T:Separator"> + <summary> + A separator holds two control side by side and divide them with a draggable line. + It can be horizontal or vertical. + </summary> + </member> + <member name="M:Separator.Draw(UnityEngine.Rect)"> + <summary> + Draw the whole region holding the two control and the separator. + The separator pass down the proper region to Draw of the sub-controls. + Returns true if the window needs to be repainted. + </summary> + </member> + <member name="P:DragEventArgs.Target"> + <summary> + Targeted object + </summary> + </member> + <member name="P:DragEventArgs.InBetween"> + <summary> + Is on top of the target + </summary> + </member> + <member name="P:DragEventArgs.Dragged"> + <summary> + Selecttion dragged + </summary> + </member> + <member name="T:EnumExtension"> + <summary> + Extends Enum with some bitfields related method. + </summary> + </member> + <member name="M:EnumExtension.Append``1(System.Enum,``0)"> + <summary> + Add a value to a bitfield. + </summary> + </member> + <member name="M:EnumExtension.Remove``1(System.Enum,``0)"> + <summary> + Remove a value from a bitfield. + </summary> + </member> + <member name="M:EnumExtension.Has``1(System.Enum,``0)"> + <summary> + Test if a bitfield has a value. + </summary> + </member> + <member name="M:EnumExtension.GetAttribute``1(System.Enum)"> + <summary> + Gets an attribute on an enum field value + </summary> + <typeparam name="T">The type of the attribute you want to retrieve</typeparam> + <param name="enumVal">The enum value</param> + <returns>The attribute of type T that exists on the enum value</returns> + </member> + <member name="T:TypeExtension"> + <summary> + Extends Enum with some bitfields related method. + </summary> + </member> + <member name="M:TypeExtension.GetBaseGenericType(System.Type)"> + <summary> + Returns the nearest parent class that is generic. + </summary> + </member> + <member name="T:AdvancedInspector.DateTimeDialog"> + <summary> + The DateTime dialog is a date picker that is day/week accurate. + </summary> + </member> + <member name="T:AdvancedInspector.ModalWindow"> + <summary> + Define a popup window that return a result. + Base class for IModal implementation. + </summary> + </member> + <member name="F:AdvancedInspector.ModalWindow.TITLEBAR"> + <summary> + Top title bar height + </summary> + </member> + <member name="F:AdvancedInspector.ModalWindow.owner"> + <summary> + The object that invoked this modal. + </summary> + </member> + <member name="F:AdvancedInspector.ModalWindow.result"> + <summary> + Internal modal result. + </summary> + </member> + <member name="M:AdvancedInspector.ModalWindow.#ctor"> + <summary> + Default constructor. + </summary> + </member> + <member name="M:AdvancedInspector.ModalWindow.OnLostFocus"> + <summary> + Invoked by Unity when the user click outside the window. + </summary> + </member> + <member name="M:AdvancedInspector.ModalWindow.Cancel"> + <summary> + Called when pressing Escape or Cancel. + </summary> + </member> + <member name="M:AdvancedInspector.ModalWindow.Ok"> + <summary> + Called when pressing Enter or Ok. + </summary> + </member> + <member name="M:AdvancedInspector.ModalWindow.Exist``1"> + <summary> + Does this specific modal type exist? + </summary> + </member> + <member name="M:AdvancedInspector.ModalWindow.OnGUI"> + <summary> + Usually you should not override this. + </summary> + </member> + <member name="M:AdvancedInspector.ModalWindow.Draw(UnityEngine.Rect)"> + <summary> + Implement your draw items here. + </summary> + </member> + <member name="P:AdvancedInspector.ModalWindow.Result"> + <summary> + Result of this modal window. + </summary> + </member> + <member name="F:AdvancedInspector.DateTimeDialog.HEIGHT"> + <summary> + Height of dialog + </summary> + </member> + <member name="F:AdvancedInspector.DateTimeDialog.WIDTH"> + <summary> + Width of dialog + </summary> + </member> + <member name="M:AdvancedInspector.DateTimeDialog.Create(AdvancedInspector.IModal,System.DateTime,UnityEngine.Vector2)"> + <summary> + Create this dialog. + </summary> + </member> + <member name="M:AdvancedInspector.DateTimeDialog.Draw(UnityEngine.Rect)"> + <summary> + Draw the dialog region. + </summary> + </member> + <member name="P:AdvancedInspector.DateTimeDialog.Time"> + <summary> + Modified DateTime if Result is Ok + </summary> + </member> + <member name="T:AdvancedInspector.Toolbox"> + <summary> + The toolbox is a generic way of display a selection to the user. + Any EditorWindow that implement IToolbox will call it when CTRL+Q is request it. + It is up to the window to fill the content of the Toolbox. + </summary> + </member> + <member name="M:AdvancedInspector.Toolbox.AddItem(System.Object,System.String,System.String,UnityEngine.Texture)"> + <summary> + Add an item to the toolbox list. + </summary> + </member> + <member name="M:AdvancedInspector.Toolbox.Create(AdvancedInspector.IModal,System.String,System.Collections.Generic.List{AdvancedInspector.DescriptorPair},UnityEngine.Vector2)"> + <summary> + Create a toolbox for this IModal. + </summary> + </member> + <member name="M:AdvancedInspector.Toolbox.Create(AdvancedInspector.IModal,System.String,System.Collections.Generic.List{AdvancedInspector.DescriptorPair},UnityEngine.Vector2,System.String)"> + <summary> + Create a toolbox for this IModal. + </summary> + </member> + <member name="M:AdvancedInspector.Toolbox.Draw(UnityEngine.Rect)"> + <summary> + IControl implementation + </summary> + </member> + <member name="P:AdvancedInspector.Toolbox.Items"> + <summary> + List of items visible by this toolbox. + </summary> + </member> + <member name="P:AdvancedInspector.Toolbox.Selection"> + <summary> + The current selection. + </summary> + </member> + <member name="P:AdvancedInspector.Toolbox.Search"> + <summary> + The search term entered in the search field. + </summary> + </member> + <member name="T:AdvancedInspector.WindowResult"> + <summary> + Result returned by a Modal Window + </summary> + </member> + <member name="F:AdvancedInspector.WindowResult.None"> + <summary> + No result, no action taken + </summary> + </member> + <member name="F:AdvancedInspector.WindowResult.Ok"> + <summary> + Ok or Enter + </summary> + </member> + <member name="F:AdvancedInspector.WindowResult.Cancel"> + <summary> + Cancel or Escape + </summary> + </member> + <member name="F:AdvancedInspector.WindowResult.Invalid"> + <summary> + An error occured + </summary> + </member> + <member name="F:AdvancedInspector.WindowResult.LostFocus"> + <summary> + User clicked outside the modal + </summary> + </member> + <member name="T:TreeView"> + <summary> + A control that is a list of item that can be nested. + Support drag and drop, editing and sorting. + </summary> + </member> + <member name="M:TreeView.BuildVisibility"> + <summary> + Refresh the list of visible item when the items list has changed. + </summary> + </member> + <member name="M:TreeView.BuildVisibility(System.Collections.Generic.List{TreeViewItem},System.Collections.Generic.List{TreeViewItem})"> + <summary> + Refresh the list of visible item when the items list has changed. + </summary> + </member> + <member name="P:TreeView.Selection"> + <summary> + Current selected tags. + </summary> + </member> + <member name="P:TreeView.Count"> + <summary> + Number of visible nodes. + </summary> + </member> + </members> +</doc> diff --git a/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.XML.meta b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.XML.meta new file mode 100644 index 00000000..55a2b378 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.XML.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e96c4a7c78e365541b0512e981e9e981 +timeCreated: 1426031802 +licenseType: Store +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.dll b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.dll Binary files differnew file mode 100644 index 00000000..86f31e26 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.dll diff --git a/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.dll.meta b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.dll.meta new file mode 100644 index 00000000..196bd820 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 09b9181468d6b774aa9b3e4e0654892d +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.pdb b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.pdb Binary files differnew file mode 100644 index 00000000..7cfacf7d --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.pdb diff --git a/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.pdb.meta b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.pdb.meta new file mode 100644 index 00000000..f65772af --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/AdvancedInspector.pdb.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 454ad4bbaca47654ba1ba02c97f6efab +timeCreated: 1426031799 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor/AdvancedInspector/Examples.meta b/Assets/Plugins/Editor/AdvancedInspector/Examples.meta new file mode 100644 index 00000000..c595a197 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/Examples.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: bbde48e2fa9194d469ae2a4b99c3729a +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/Examples/ExternalInspectorWindow.cs b/Assets/Plugins/Editor/AdvancedInspector/Examples/ExternalInspectorWindow.cs new file mode 100644 index 00000000..e1a7cdac --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/Examples/ExternalInspectorWindow.cs @@ -0,0 +1,76 @@ +using UnityEngine; +using UnityEditor; + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +using AdvancedInspector; + +public class ExternalInspectorWindow : EditorWindow +{ + private ExternalEditor editor; + + private GameObject go; + private Component component; + + [MenuItem("Window/Advanced Insector Example")] + public static void Init() + { + ExternalInspectorWindow window = EditorWindow.GetWindow<ExternalInspectorWindow>(); + window.wantsMouseMove = true; + window.editor = ExternalEditor.CreateInstance<ExternalEditor>(); + + window.editor.DraggableSeparator = false; + window.editor.DivisionSeparator = 150; + } + + private void OnSelectionChange() + { + go = Selection.activeGameObject; + Repaint(); + } + + private void OnGUI() + { + if (go == null) + { + GUILayout.Label("Select a GameObject..."); + component = null; + editor.Instances = new object[0]; + } + else + { + Component[] components = go.GetComponents(typeof(Component)); + GUIContent[] contents = new GUIContent[components.Length + 1]; + contents[0] = new GUIContent("None"); + int index = -1; + for (int i = 0; i < components.Length; i++) + { + contents[i + 1] = new GUIContent(components[i].GetType().Name); + if (components[i] == component) + index = i + 1; + } + + EditorGUI.BeginChangeCheck(); + index = EditorGUILayout.Popup(new GUIContent("Select a component: "), index, contents); + if (EditorGUI.EndChangeCheck()) + { + if (index == 0) + { + component = null; + editor.Instances = new object[0]; + } + else + { + component = components[index - 1]; + editor.Instances = new object[] { component }; + } + } + } + + if (editor.Draw(new Rect(0, 16, position.width, position.height - 16))) + Repaint(); + } +} diff --git a/Assets/Plugins/Editor/AdvancedInspector/Examples/ExternalInspectorWindow.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/Examples/ExternalInspectorWindow.cs.meta new file mode 100644 index 00000000..a7870aa5 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/Examples/ExternalInspectorWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c9740780a68d7d744b5281622bbd706b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI.meta b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI.meta new file mode 100644 index 00000000..8c84ce35 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: a52feea1ebf19884bb717531c7fd0cac +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs new file mode 100644 index 00000000..4219fa75 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using UnityEngine; +using UnityEditor; + +using UniToolsEditor; + +namespace AdvancedInspector +{ + public static class ExtraGUI + { + private static Texture knob; + + private static Texture Knob + { + get + { + if (knob == null) + { + knob = Helper.Load(EditorResources.Knob); + knob.filterMode = FilterMode.Trilinear; + } + + return knob; + } + } + + private static Texture knobBack; + + private static Texture KnobBack + { + get + { + if (knobBack == null) + knobBack = Helper.Load(EditorResources.KnobBack); + + return knobBack; + } + } + + private static Vector2 mousePosition; + + public static float FloatAngle(Rect rect, float value) + { + return FloatAngle(rect, value, -1, -1, -1); + } + + public static float FloatAngle(Rect rect, float value, float snap) + { + return FloatAngle(rect, value, snap, -1, -1); + } + + public static float FloatAngle(Rect rect, float value, float snap, float min, float max) + { + int id = GUIUtility.GetControlID(FocusType.Passive, rect); + + Rect knobRect = new Rect(rect.x, rect.y, rect.height, rect.height); + + float delta; + if (min != max) + delta = ((max - min) / 360); + else + delta = 1; + + if (Event.current != null) + { + if (Event.current.type == EventType.MouseDown && knobRect.Contains(Event.current.mousePosition)) + { + GUIUtility.hotControl = id; + mousePosition = Event.current.mousePosition; + } + else if (Event.current.type == EventType.MouseUp && GUIUtility.hotControl == id) + GUIUtility.hotControl = 0; + else if (Event.current.type == EventType.MouseDrag && GUIUtility.hotControl == id) + { + Vector2 move = mousePosition - Event.current.mousePosition; + value += delta * (-move.x - move.y); + + if (snap > 0) + { + float mod = value % snap; + + if (mod < (delta * 3) || Mathf.Abs(mod - snap) < (delta * 3)) + value = Mathf.Round(value / snap) * snap; + } + + mousePosition = Event.current.mousePosition; + GUI.changed = true; + } + } + + GUI.DrawTexture(knobRect, KnobBack); + Matrix4x4 matrix = GUI.matrix; + + if (min != max) + GUIUtility.RotateAroundPivot(value * (360 / (max - min)), knobRect.center); + else + GUIUtility.RotateAroundPivot(value, knobRect.center); + + GUI.DrawTexture(knobRect, Knob); + GUI.matrix = matrix; + + Rect label = new Rect(rect.x + rect.height + 9, rect.y + (rect.height / 2) - 9, rect.height, 18); + value = EditorGUI.FloatField(label, value); + + if (min != max) + value = Mathf.Clamp(value, min, max); + + return value; + } + + public static int IntAngle(Rect rect, int value) + { + return IntAngle(rect, value, -1, -1, -1); + } + + public static int IntAngle(Rect rect, int value, int snap) + { + return IntAngle(rect, value, snap, -1, -1); + } + + public static int IntAngle(Rect rect, int value, int snap, int min, int max) + { + int id = GUIUtility.GetControlID(FocusType.Passive, rect); + + Rect knobRect = new Rect(rect.x, rect.y, rect.height, rect.height); + + int delta; + if (min != max) + delta = ((max - min) / 360); + else + delta = 1; + + if (Event.current != null) + { + if (Event.current.type == EventType.MouseDown && knobRect.Contains(Event.current.mousePosition)) + { + GUIUtility.hotControl = id; + mousePosition = Event.current.mousePosition; + } + else if (Event.current.type == EventType.MouseUp && GUIUtility.hotControl == id) + GUIUtility.hotControl = 0; + else if (Event.current.type == EventType.MouseDrag && GUIUtility.hotControl == id) + { + Vector2 move = mousePosition - Event.current.mousePosition; + value += delta * (-(int)move.x - (int)move.y); + + if (snap > 0) + { + float mod = value % snap; + + if (mod < (delta * 3) || Mathf.Abs(mod - snap) < (delta * 3)) + value = (int)Mathf.Round(value / snap) * snap; + } + + mousePosition = Event.current.mousePosition; + GUI.changed = true; + } + } + + GUI.DrawTexture(knobRect, KnobBack); + Matrix4x4 matrix = GUI.matrix; + + if (min != max) + GUIUtility.RotateAroundPivot(value * (360 / (max - min)), knobRect.center); + else + GUIUtility.RotateAroundPivot(value, knobRect.center); + + GUI.DrawTexture(knobRect, Knob); + GUI.matrix = matrix; + + Rect label = new Rect(rect.x + rect.height + 9, rect.y + (rect.height / 2) - 9, rect.height, 18); + value = EditorGUI.IntField(label, value); + + if (min != max) + value = Mathf.Clamp(value, min, max); + + return value; + } + + public static int CycleButton(Rect rect, int selected, GUIContent[] contents, GUIStyle style) + { + if (GUI.Button(rect, contents[selected], style)) + { + selected++; + if (selected >= contents.Length) + selected = 0; + } + + return selected; + } + } +} diff --git a/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs.meta new file mode 100644 index 00000000..82b25bc2 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e020a2d8f59a2864999a0b1bce4e072e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUILayout.cs b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUILayout.cs new file mode 100644 index 00000000..608a45f5 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUILayout.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using UnityEngine; +using UnityEditor; + +namespace AdvancedInspector +{ + public static class ExtraGUILayout + { + public static float FloatAngle(float value) + { + return FloatAngle(value, -1, -1, -1); + } + + public static float FloatAngle(float value, float snap) + { + return FloatAngle(value, snap, -1, -1); + } + + public static float FloatAngle(float value, float snap, float min, float max) + { + Rect rect = GUILayoutUtility.GetRect(128, 512, 32, 32); + rect.x += 8; + return ExtraGUI.FloatAngle(rect, value, snap, min, max); + } + + public static int IntAngle(int value) + { + return IntAngle(value, -1, -1, -1); + } + + public static int IntAngle(int value, int snap) + { + return IntAngle(value, snap, -1, -1); + } + + public static int IntAngle(int value, int snap, int min, int max) + { + Rect rect = GUILayoutUtility.GetRect(128, 512, 32, 32); + rect.x += 8; + return ExtraGUI.IntAngle(rect, value, snap, min, max); + } + + public static int CycleButton(int selected, GUIContent[] contents, GUIStyle style) + { + if (GUILayout.Button(contents[selected], style)) + { + selected++; + if (selected >= contents.Length) + selected = 0; + } + + return selected; + } + } +} diff --git a/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUILayout.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUILayout.cs.meta new file mode 100644 index 00000000..37dfd46d --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUILayout.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5a5c459bbc6263843ad47a5a586832ce +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors.meta new file mode 100644 index 00000000..4977dd9e --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: ab0ea0ba2acfe2e4ebd1654a33714ef2 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/AnimationCurveEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/AnimationCurveEditor.cs new file mode 100644 index 00000000..e5514427 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/AnimationCurveEditor.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class AnimationCurveEditor : FieldEditor + { + public override Type[] EditedTypes + { + get { return new Type[] { typeof(AnimationCurve) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + AnimationCurve curve = GetValue(field) as AnimationCurve; + if (curve == null && !field.Mixed) + curve = new AnimationCurve(); + + EditorGUI.BeginChangeCheck(); + + AnimationCurve result = EditorGUILayout.CurveField(curve); + + if (EditorGUI.EndChangeCheck()) + field.SetValue(result); + } + } +} diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/AnimationCurveEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/AnimationCurveEditor.cs.meta new file mode 100644 index 00000000..5a6ec81d --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/AnimationCurveEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 175374f05b4f81243bd565df4b3842ac +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BooleanEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BooleanEditor.cs new file mode 100644 index 00000000..f4d25a86 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BooleanEditor.cs @@ -0,0 +1,30 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class BooleanEditor : FieldEditor + { + public override Type[] EditedTypes + { + get { return new Type[] { typeof(bool) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + object value = GetValue(field); + + EditorGUI.BeginChangeCheck(); + bool result; + if (style != null) + result = EditorGUILayout.Toggle((bool)value, style); + else + result = EditorGUILayout.Toggle((bool)value); + + if (EditorGUI.EndChangeCheck()) + field.SetValue(result); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BooleanEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BooleanEditor.cs.meta new file mode 100644 index 00000000..7013dc4e --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BooleanEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3ed44e8dcffbde44eb2efd1c009248c6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BoundsEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BoundsEditor.cs new file mode 100644 index 00000000..773201e1 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BoundsEditor.cs @@ -0,0 +1,134 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class BoundsEditor : FieldEditor + { + public override bool Expandable + { + get { return false; } + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(Bounds) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + float labelWidth = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = VECTOR_FIELD_WIDTH; + + Bounds[] values = field.GetValues<Bounds>(); + + float[] centerX = new float[values.Length]; + float[] centerY = new float[values.Length]; + float[] centerZ = new float[values.Length]; + float[] extendX = new float[values.Length]; + float[] extendY = new float[values.Length]; + float[] extendZ = new float[values.Length]; + + for (int i = 0; i < values.Length; i++) + { + centerX[i] = values[i].center.x; + centerY[i] = values[i].center.y; + centerZ[i] = values[i].center.z; + extendX[i] = values[i].extents.x; + extendY[i] = values[i].extents.y; + extendZ[i] = values[i].extents.z; + } + + GUILayout.BeginHorizontal(); + float result; + EditorGUILayout.LabelField("Center: ", GUILayout.Width(48)); + if (FloatEditor.DrawFloat("X", centerX, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Center X"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Vector3 center = values[i].center; + center.x = result; + values[i].center = center; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Y", centerY, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Center Y"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Vector3 center = values[i].center; + center.y = result; + values[i].center = center; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Z", centerZ, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Center Z"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Vector3 center = values[i].center; + center.z = result; + values[i].center = center; + field.SetValue(field.Instances[i], values[i]); + } + } + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Extend: ", GUILayout.Width(48)); + if (FloatEditor.DrawFloat("X", extendX, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Extend X"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Vector3 extents = values[i].extents; + extents.x = result; + values[i].extents = extents; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Y", extendY, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Extend Y"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Vector3 extents = values[i].extents; + extents.y = result; + values[i].extents = extents; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Z", extendZ, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Extend Z"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Vector3 extents = values[i].extents; + extents.z = result; + values[i].extents = extents; + field.SetValue(field.Instances[i], values[i]); + } + } + GUILayout.EndHorizontal(); + + EditorGUILayout.Space(); + + EditorGUIUtility.labelWidth = labelWidth; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BoundsEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BoundsEditor.cs.meta new file mode 100644 index 00000000..a51cf2ca --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/BoundsEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1c18b641c92f5f44eb38e807d2feed74 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/CharEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/CharEditor.cs new file mode 100644 index 00000000..2a82f0ea --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/CharEditor.cs @@ -0,0 +1,40 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class CharEditor : FieldEditor + { + public override Type[] EditedTypes + { + get { return new Type[] { typeof(char) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + GUILayout.BeginHorizontal(); + + object value = GetValue(field); + string text = ""; + if (value != null) + text = value.ToString(); + + EditorGUI.BeginChangeCheck(); + + string result = EditorGUILayout.TextField(text); + + char c; + if (result.Length == 0) + c = '\0'; + else + c = result[0]; + + if (EditorGUI.EndChangeCheck()) + field.SetValue(c); + + GUILayout.EndHorizontal(); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/CharEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/CharEditor.cs.meta new file mode 100644 index 00000000..e9be5d8b --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/CharEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b97d572b1c98e564f91d1a16c55cabc3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ColorEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ColorEditor.cs new file mode 100644 index 00000000..c8974082 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ColorEditor.cs @@ -0,0 +1,49 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class ColorEditor : FieldEditor + { + public override bool Expandable + { + get { return false; } + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(Color), typeof(Color32) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + object o = GetValue(field); + Type type = o.GetType(); + + Color color; + if (type == typeof(Color32)) + { + Color32 color32 = (Color32)o; + color = color32; + } + else + color = (Color)o; + + EditorGUI.BeginChangeCheck(); + color = EditorGUILayout.ColorField(color); + + if (EditorGUI.EndChangeCheck()) + { + if (type == typeof(Color32)) + { + Color32 color32 = color; + field.SetValue(color32); + } + else + field.SetValue(color); + } + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ColorEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ColorEditor.cs.meta new file mode 100644 index 00000000..e2813cf6 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ColorEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 95ebae573d4fa724eb1787d862581a82 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/DateTimeEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/DateTimeEditor.cs new file mode 100644 index 00000000..de120b87 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/DateTimeEditor.cs @@ -0,0 +1,69 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +using UniToolsEditor; + +namespace AdvancedInspector +{ + public class DateTimeEditor : FieldEditor, IModal + { + private InspectorField field; + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(DateTime) }; } + } + + private static Texture calendar; + + internal static Texture Calendar + { + get + { + if (calendar == null) + calendar = Helper.Load(EditorResources.Calendar); + + return calendar; + } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + DateTime time = field.GetValue<DateTime>(); + if (time == DateTime.MinValue) + time = DateTime.Now; + + string title = time.ToString(); + if (field.Mixed) + title = " - - - "; + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.Space(); + if (GUILayout.Button(Calendar, GUIStyle.none, GUILayout.Width(18), GUILayout.Height(18))) + { + this.field = field; + DateTimeDialog.Create(this, time, GUIUtility.GUIToScreenPoint(Event.current.mousePosition)); + } + + TextAnchor anchor = GUI.skin.label.alignment; + GUI.skin.label.alignment = TextAnchor.MiddleLeft; + GUILayout.Label(title); + GUI.skin.label.alignment = anchor; + + GUILayout.FlexibleSpace(); + EditorGUILayout.EndHorizontal(); + } + + public void ModalRequest(bool shift) { } + + public void ModalClosed(ModalWindow window) + { + if (window.Result != WindowResult.Ok) + return; + + field.SetValue(((DateTimeDialog)window).Time); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/DateTimeEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/DateTimeEditor.cs.meta new file mode 100644 index 00000000..f247aa3f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/DateTimeEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4176afc2bf64fb4cb22c40d470180a7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/EnumEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/EnumEditor.cs new file mode 100644 index 00000000..627aba7c --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/EnumEditor.cs @@ -0,0 +1,192 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace AdvancedInspector +{ + public class EnumEditor : FieldEditor + { + public override bool EditDerived + { + get { return true; } + } + + public override bool Expandable + { + get { return false; } + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(Enum) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + EnumAttribute display = field.GetAttribute<EnumAttribute>(); + + EditorGUI.showMixedValue = field.Mixed; + + EditorGUI.BeginChangeCheck(); + + object result = null; + long value = Convert.ToInt64(GetValue(field)); + if (display == null || !display.Masked) + { + if (display == null || display.Display == EnumDisplay.DropDown) + result = DrawDropDown(field.Type, value, style, false); + else if (display.Display == EnumDisplay.Button) + result = DrawEnum(field.Type, value, display.MaxItemsPerRow, style == null ? EditorStyles.toolbarButton : style); + else if (display.Display == EnumDisplay.Checkbox) + result = DrawEnum(field.Type, value, display.MaxItemsPerRow, style == null ? EditorStyles.toggle : style); + } + else + { + if (display == null || display.Display == EnumDisplay.DropDown) + result = DrawDropDown(field.Type, value, style, true); + else if (display.Display == EnumDisplay.Button) + result = DrawMasked(field.Type, value, display.MaxItemsPerRow, style == null ? EditorStyles.toolbarButton : style); + else if (display.Display == EnumDisplay.Checkbox) + result = DrawMasked(field.Type, value, display.MaxItemsPerRow, style == null ? EditorStyles.toggle : style); + } + + if (EditorGUI.EndChangeCheck()) + field.SetValue(result); + } + + private int SelectedIndex(Array values, long value) + { + for (int i = 0; i < values.Length; i++) + if (Convert.ToInt64(values.GetValue(i)) == value) + return i; + + return 0; + } + + private string[] GetNames(Type type) + { + Array values = Enum.GetValues(type); + List<string> names = Enum.GetNames(type).ToList(); + + for (int i = 0; i < names.Count; i++) + { + DescriptorAttribute descriptor = ((Enum)values.GetValue(i)).GetAttribute<DescriptorAttribute>(); + if (descriptor != null && !string.IsNullOrEmpty(descriptor.Name)) + names[i] = descriptor.Name; + else + names[i] = ObjectNames.NicifyVariableName(names[i]); + } + + return names.ToArray(); + } + + private object DrawDropDown(Type type, long value, GUIStyle style, bool masked) + { + string[] names = GetNames(type); + Array values = Enum.GetValues(type); + + if (masked) + { + if (style == null) + value = EditorGUILayout.MaskField(Convert.ToInt32(value), names); + else + value = EditorGUILayout.MaskField(Convert.ToInt32(value), names, style); + + return Enum.ToObject(type, value); + } + else + { + int selected = SelectedIndex(values, value); + + if (style == null) + selected = EditorGUILayout.Popup(selected, names); + else + selected = EditorGUILayout.Popup(selected, names, style); + + return Enum.ToObject(type, values.GetValue(selected)); + } + } + + private object DrawEnum(Type type, long value, int max, GUIStyle style) + { + if (max < 1) + max = 6; + + string[] names = GetNames(type); + Array values = Enum.GetValues(type); + + int rows = Mathf.CeilToInt((float)names.Length / (float)max); + int count = (names.Length / rows); + if (count * rows < names.Length) + count++; + + int selected = SelectedIndex(values, value); + + GUILayout.BeginVertical(); + + for (int i = 0; i < rows; i++) + { + GUILayout.BeginHorizontal(); + + for (int j = count * i; j < count * (i + 1); j++) + { + if (j >= names.Length) + break; + + if (selected == j) + GUILayout.Toggle(true, names[j], style); + else if (GUILayout.Toggle(false, names[j], style)) + selected = j; + } + + GUILayout.EndHorizontal(); + } + + GUILayout.EndVertical(); + + return Enum.ToObject(type, values.GetValue(selected)); + } + + private object DrawMasked(Type type, long value, int max, GUIStyle style) + { + if (max < 1) + max = 6; + + Array values = Enum.GetValues(type); + string[] names = GetNames(type); + + int rows = Mathf.CeilToInt((float)names.Length / (float)max); + int count = (names.Length / rows); + if (count * rows < names.Length) + count++; + + int result = 0; + + GUILayout.BeginVertical(); + + for (int i = 0; i < rows; i++) + { + GUILayout.BeginHorizontal(); + + for (int j = count * i; j < count * (i + 1); j++) + { + if (j >= names.Length) + break; + + int v = (int)values.GetValue(j); + if (GUILayout.Toggle(((int)value & v) == v, names[j], style)) + result |= v; + } + + GUILayout.EndHorizontal(); + } + + GUILayout.EndVertical(); + + return Enum.ToObject(type, result); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/EnumEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/EnumEditor.cs.meta new file mode 100644 index 00000000..e8d95004 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/EnumEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 60d56c7709f5e334c837239c33327bbd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/FloatEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/FloatEditor.cs new file mode 100644 index 00000000..d139c02f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/FloatEditor.cs @@ -0,0 +1,208 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class FloatEditor : FieldEditor + { + public override Type[] EditedTypes + { + get { return new Type[] { typeof(float), typeof(decimal), typeof(double) }; } + } + + public override void OnLabelDraw(InspectorField field, Rect rect) + { + if (InspectorPreferences.IsDragControl(InspectorPreferences.ValueScroll)) + EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeHorizontal); + } + + public override void OnLabelClick(InspectorField field) + { + EditorGUIUtility.SetWantsMouseJumping(1); + } + + public override void OnLabelDragged(InspectorField field) + { + if (InspectorPreferences.IsDragControl(InspectorPreferences.ValueScroll)) + { + object result = field.GetValues()[0]; + double sensitivity = CalculateDragSensitivity(result); + result = Convert.ToDouble(result) + (double)(sensitivity * HandleUtility.niceMouseDelta); + + RangeValueAttribute rangeValue = field.GetAttribute<RangeValueAttribute>(); + if (rangeValue != null) + result = Math.Min(Math.Max((double)result, rangeValue.Min), rangeValue.Max); + + RangeAttribute range = field.GetAttribute<RangeAttribute>(); + if (range != null) + result = Math.Min(Math.Max((double)result, range.min), range.max); + + try + { + result = Convert.ChangeType(result, field.Type); + field.SetValue(result); + } + catch (Exception) + { + return; + } + } + } + + private static double CalculateDragSensitivity(object value) + { + double number = Convert.ToDouble(value); + + if (!double.IsInfinity(number) && !double.IsNaN(number)) + return (Math.Max(1d, Math.Pow(Math.Abs(number), 0.5d)) * 0.03d); + + return 0d; + } + + public override void Draw(InspectorField field, GUIStyle style) + { + RangeValueAttribute rangeValue = field.GetAttribute<RangeValueAttribute>(); + RangeAttribute range = field.GetAttribute<RangeAttribute>(); + + if (range != null && rangeValue == null) + rangeValue = new RangeValueAttribute(range.min, range.max); + + AngleAttribute angle = field.GetAttribute<AngleAttribute>(); + + object result; + if (DrawFloatingNumber(new GUIContent(""), field.GetValues(), rangeValue, angle, style, out result)) + field.SetValue(result); + } + + public static bool DrawFloat(string label, float[] values, out float result, params GUILayoutOption[] options) + { + return DrawFloat(label, values, null, null, null, out result, options); + } + + public static bool DrawFloat(string label, float[] values, GUIStyle style, out float result, params GUILayoutOption[] options) + { + return DrawFloat(label, values, null, null, style, out result, options); + } + + public static bool DrawFloat(string label, float[] values, RangeValueAttribute range, AngleAttribute angle, GUIStyle style, out float result, params GUILayoutOption[] options) + { + object genericResult; + object[] genericValues = new object[values.Length]; + for (int i = 0; i < values.Length; i++) + genericValues[i] = values[i]; + + bool changed = DrawFloatingNumber(new GUIContent(label), genericValues, range, angle, style, out genericResult, options); + + try + { + result = (float)genericResult; + } + catch (Exception) + { + result = values[0]; + return false; + } + + return changed; + } + + public static bool DrawFloatingNumber(GUIContent label, object[] values, RangeValueAttribute range, AngleAttribute angle, GUIStyle style, out object result, params GUILayoutOption[] options) + { + result = 0; + + EditorGUI.showMixedValue = false; + result = values[0]; + Type type = result.GetType(); + for (int i = 1; i < values.Length; i++) + { + if (values[i].Equals(result)) + continue; + + EditorGUI.showMixedValue = true; + break; + } + + EditorGUI.BeginChangeCheck(); + EditorGUILayout.BeginHorizontal(); + + if (!string.IsNullOrEmpty(label.text)) + { + int size = (int)GUI.skin.label.CalcSize(label).x; + if (size > 4) + size = Mathf.Max(size, 15); + + GUILayout.Label(label, GUI.skin.label, GUILayout.Width(size)); + + Event e = Event.current; + Rect labelRect = GUILayoutUtility.GetLastRect(); + int id = EditorGUIUtility.GetControlID(FocusType.Passive, labelRect); + + if (InspectorPreferences.IsDragControl(InspectorPreferences.ValueScroll)) + { + if (e.type == EventType.Repaint) + { + EditorGUIUtility.AddCursorRect(labelRect, MouseCursor.ResizeHorizontal); + } + else if (e.type == EventType.MouseDown && labelRect.Contains(e.mousePosition) && e.button == 0) + { + GUIUtility.hotControl = id; + GUIUtility.keyboardControl = id; + EditorGUIUtility.SetWantsMouseJumping(1); + e.Use(); + } + else if (e.type == EventType.MouseDrag && GUIUtility.hotControl == id) + { + double sensitivity = CalculateDragSensitivity(result); + result = Convert.ToDecimal(result) + (decimal)(sensitivity * HandleUtility.niceMouseDelta); + + if (range != null) + result = Math.Min(Math.Max((double)result, (double)range.Min), (double)range.Max); + + GUI.changed = true; + e.Use(); + } + else if (e.type == EventType.MouseUp && GUIUtility.hotControl == id) + { + GUIUtility.hotControl = 0; + EditorGUIUtility.SetWantsMouseJumping(0); + e.Use(); + } + } + } + + if (angle != null) + { + if (range != null) + result = ExtraGUILayout.FloatAngle((float)result, angle.Snap, range.Min, range.Max); + else + result = ExtraGUILayout.FloatAngle((float)result, angle.Snap); + } + else + { + if (range != null) + result = EditorGUILayout.Slider((float)result, range.Min, range.Max, options); + else + { + if (style != null) + result = EditorGUILayout.TextField(result.ToString(), style, options); + else + result = EditorGUILayout.TextField(result.ToString(), options); + } + } + + try + { + result = Convert.ChangeType(result, type); + } + catch (Exception) + { + return false; + } + + EditorGUILayout.EndHorizontal(); + return EditorGUI.EndChangeCheck(); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/FloatEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/FloatEditor.cs.meta new file mode 100644 index 00000000..edfb7b23 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/FloatEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4724a82f5fd3d9e44a50d524deae4259 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GradientEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GradientEditor.cs new file mode 100644 index 00000000..09910618 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GradientEditor.cs @@ -0,0 +1,36 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; +using System.Reflection; + +namespace AdvancedInspector +{ + public class GradientEditor : FieldEditor + { + private static MethodInfo gradientField; + + public GradientEditor() + { + // Because Unity does not expose this EditorGUI. + gradientField = typeof(EditorGUILayout).GetMethod("GradientField", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(Gradient), typeof(GUILayoutOption).MakeArrayType() }, null); + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(Gradient) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + object value = GetValue(field); + + try + { + //Always throw "ExitGUIException" + gradientField.Invoke(null, new object[] { value, null }); + } + catch (Exception) { } + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GradientEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GradientEditor.cs.meta new file mode 100644 index 00000000..275d4027 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GradientEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 96cba1c5f2f4273468699cb64ae8726e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GuidEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GuidEditor.cs new file mode 100644 index 00000000..43fd51c9 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GuidEditor.cs @@ -0,0 +1,25 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class GuidEditor : FieldEditor + { + public override Type[] EditedTypes + { + get { return new Type[] { typeof(Guid) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + // GetValue returns null if multi-selection and different values + Guid id = field.GetValue<Guid>(); + if (id == Guid.Empty) + GUILayout.Label("GUID: --------------"); + else + GUILayout.Label("GUID: " + id.ToString()); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GuidEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GuidEditor.cs.meta new file mode 100644 index 00000000..15843f11 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/GuidEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 054dd34a1ddeb8b46848fcc673189bab +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/IntegerEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/IntegerEditor.cs new file mode 100644 index 00000000..c88f59f2 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/IntegerEditor.cs @@ -0,0 +1,195 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class IntegerEditor : FieldEditor + { + public override Type[] EditedTypes + { + get { return new Type[] { typeof(int), typeof(byte), typeof(short), typeof(long), typeof(uint), typeof(ushort), typeof(ulong), typeof(sbyte) }; } + } + + public override void OnLabelDraw(InspectorField field, Rect rect) + { + if (InspectorPreferences.IsDragControl(InspectorPreferences.ValueScroll)) + EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeHorizontal); + } + + public override void OnLabelClick(InspectorField field) + { + EditorGUIUtility.SetWantsMouseJumping(1); + } + + public override void OnLabelDragged(InspectorField field) + { + if (InspectorPreferences.IsDragControl(InspectorPreferences.ValueScroll)) + { + object result = field.GetValues()[0]; + long value = Convert.ToInt64(result); + result = (long)Math.Round(value + (CalculateDragSensitivity(value) * HandleUtility.niceMouseDelta * 0.1f)); + + RangeValueAttribute rangeValue = field.GetAttribute<RangeValueAttribute>(); + if (rangeValue != null) + result = Math.Min(Math.Max((long)result, (long)rangeValue.Min), (long)rangeValue.Max); + + RangeAttribute range = field.GetAttribute<RangeAttribute>(); + if (range != null) + result = Math.Min(Math.Max((long)result, (long)range.min), (long)range.max); + + try + { + result = Convert.ChangeType(result, field.Type); + field.SetValue(result); + } + catch (Exception) + { + return; + } + } + } + + private static double CalculateDragSensitivity(object value) + { + return Math.Max(1, Math.Pow(Math.Abs((long)value), 0.5d) * 0.03d); + } + + public override void Draw(InspectorField field, GUIStyle style) + { + AngleAttribute angle = field.GetAttribute<AngleAttribute>(); + + RangeValueAttribute rangeValue = field.GetAttribute<RangeValueAttribute>(); + RangeAttribute range = field.GetAttribute<RangeAttribute>(); + + if (range != null && rangeValue == null) + rangeValue = new RangeValueAttribute(range.min, range.max); + + object result; + if (DrawIntegerNumber(GUIContent.none, field.GetValues(), rangeValue, angle, style, out result)) + field.SetValue(result); + } + + public static bool DrawInt(string label, int[] values, out int result, params GUILayoutOption[] options) + { + return DrawInt(label, values, null, out result, options); + } + + public static bool DrawInt(string label, int[] values, GUIStyle style, out int result, params GUILayoutOption[] options) + { + object genericResult; + object[] genericValues = new object[values.Length]; + for (int i = 0; i < values.Length; i++) + genericValues[i] = values[i]; + + bool changed = DrawIntegerNumber(new GUIContent(label), genericValues, null, null, style, out genericResult, options); + + try + { + result = (int)genericResult; + } + catch (Exception) + { + result = values[0]; + return false; + } + + return changed; + } + + public static bool DrawIntegerNumber(GUIContent label, object[] values, RangeValueAttribute range, AngleAttribute angle, GUIStyle style, out object result, params GUILayoutOption[] options) + { + EditorGUI.showMixedValue = false; + result = values[0]; + Type type = result.GetType(); + for (int i = 1; i < values.Length; i++) + { + if (values[i].Equals(result)) + continue; + + EditorGUI.showMixedValue = true; + break; + } + + EditorGUI.BeginChangeCheck(); + EditorGUILayout.BeginHorizontal(); + + if (!string.IsNullOrEmpty(label.text)) + { + int size = (int)GUI.skin.label.CalcSize(label).x; + if (size > 4) + size = Mathf.Max(size, 15); + + GUILayout.Label(label, GUI.skin.label, GUILayout.Width(size)); + + Event e = Event.current; + Rect labelRect = GUILayoutUtility.GetLastRect(); + int id = EditorGUIUtility.GetControlID(FocusType.Passive, labelRect); + + if (InspectorPreferences.IsDragControl(InspectorPreferences.ValueScroll)) + { + if (e.type == EventType.Repaint) + { + EditorGUIUtility.AddCursorRect(labelRect, MouseCursor.ResizeHorizontal); + } + else if (e.type == EventType.MouseDown && labelRect.Contains(e.mousePosition) && e.button == 0) + { + GUIUtility.hotControl = id; + GUIUtility.keyboardControl = id; + EditorGUIUtility.SetWantsMouseJumping(1); + e.Use(); + } + else if (e.type == EventType.MouseDrag && GUIUtility.hotControl == id) + { + long value = Convert.ToInt64(result); + result = (long)Math.Round(value + (CalculateDragSensitivity(value) * HandleUtility.niceMouseDelta * 0.1f)); + if (range != null) + result = Math.Min(Math.Max((long)result, (long)range.Min), (long)range.Max); + + GUI.changed = true; + e.Use(); + } + else if (e.type == EventType.MouseUp && GUIUtility.hotControl == id) + { + GUIUtility.hotControl = 0; + EditorGUIUtility.SetWantsMouseJumping(0); + e.Use(); + } + } + } + + if (angle != null) + { + if (range != null) + result = ExtraGUILayout.IntAngle((int)result, (int)angle.Snap, (int)range.Min, (int)range.Max); + else + result = ExtraGUILayout.IntAngle((int)result, (int)angle.Snap); + } + else + { + if (range != null) + result = EditorGUILayout.IntSlider((int)result, (int)range.Min, (int)range.Max, options); + else + { + if (style != null) + result = EditorGUILayout.TextField(result.ToString(), style, options); + else + result = EditorGUILayout.TextField(result.ToString(), options); + } + } + + try + { + result = Convert.ChangeType(result, type); + } + catch (Exception) + { + return false; + } + + EditorGUILayout.EndHorizontal(); + return EditorGUI.EndChangeCheck(); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/IntegerEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/IntegerEditor.cs.meta new file mode 100644 index 00000000..21f570b6 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/IntegerEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c1396463f395614b976eb98c848bfa5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/LayerMaskEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/LayerMaskEditor.cs new file mode 100644 index 00000000..a007f1b6 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/LayerMaskEditor.cs @@ -0,0 +1,104 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; +using System.Collections.Generic; + +namespace AdvancedInspector +{ + public class LayerMaskEditor : FieldEditor + { + private static List<string> names; + private static List<int> masks; + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(LayerMask) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + names = new List<string>(); + masks = new List<int>(); + + for (int i = 0; i < 32; i++) + { + string name = LayerMask.LayerToName(i); + + if (!string.IsNullOrEmpty(name)) + { + names.Add(name); + masks.Add(1 << i); + } + } + + object value = field.GetValue(); + + bool isMask = value is LayerMask; + + int mask; + if (isMask) + mask = (int)(LayerMask)value; + else + mask = (int)value; + + int result; + if (DrawLayerMaskField(mask, style, out result)) + { + if (isMask) + field.SetValue((LayerMask)result); + else + field.SetValue(result); + } + } + + public static bool DrawLayerMaskField(int aMask, GUIStyle style, out int result) + { + int val = aMask; + int maskVal = 0; + for (int i = 0; i < names.Count; i++) + { + if (masks[i] != 0) + { + if ((val & masks[i]) == masks[i]) + maskVal |= 1 << i; + } + else if (val == 0) + maskVal |= 1 << i; + } + + EditorGUI.BeginChangeCheck(); + + int newMaskVal; + if (style != null) + newMaskVal = EditorGUILayout.MaskField(maskVal, names.ToArray(), style); + else + newMaskVal = EditorGUILayout.MaskField(maskVal, names.ToArray()); + + int changes = maskVal ^ newMaskVal; + + for (int i = 0; i < masks.Count; i++) + { + if ((changes & (1 << i)) != 0) + { + if ((newMaskVal & (1 << i)) != 0) + { + if (masks[i] == 0) + { + val = 0; + break; + } + else + val |= masks[i]; + } + else + val &= ~masks[i]; + } + } + + result = val; + + return EditorGUI.EndChangeCheck(); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/LayerMaskEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/LayerMaskEditor.cs.meta new file mode 100644 index 00000000..404c93c3 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/LayerMaskEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8da80cb340d7b8b4b817f05fbae4e554 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs new file mode 100644 index 00000000..92083794 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs @@ -0,0 +1,78 @@ +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 diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs.meta new file mode 100644 index 00000000..d796dee7 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/MonoEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b9fbe9f800efcf241b78c75454f58a12 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ObjectEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ObjectEditor.cs new file mode 100644 index 00000000..ddfe8b55 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ObjectEditor.cs @@ -0,0 +1,192 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UniToolsEditor; + +namespace AdvancedInspector +{ + public class ObjectEditor : FieldEditor + { + private static Texture picker; + + private static Texture pickerPro; + + private static Texture Picker + { + get + { + if (EditorGUIUtility.isProSkin) + { + if (pickerPro == null) + pickerPro = Helper.Load(EditorResources.PickerPro); + + return pickerPro; + } + else + { + if (picker == null) + picker = Helper.Load(EditorResources.Picker); + + return picker; + } + } + } + + private static int s_ObjectFieldHash = "s_ObjectFieldHash".GetHashCode(); + private static Type validator = null; + private static MethodInfo doObjectField = null; + + public override bool EditDerived + { + get { return true; } + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(UnityEngine.Object) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + if (field.GetAttribute<NoPicker>() != null) + { + object obj = field.GetValue(); + if (field.Mixed) + GUILayout.Label("---"); + else if (obj == null) + GUILayout.Label("None"); + else if (field.OverloadToString) + GUILayout.Label(obj.ToString()); + else if (field.Type != null) + GUILayout.Label(field.Type.Name); + + return; + } + + if (field.DisplayAsParent) + return; + + if (validator == null) + validator = typeof(EditorGUI).GetNestedType("ObjectFieldValidator", BindingFlags.NonPublic); + + if (doObjectField == null) + doObjectField = typeof(EditorGUI).GetMethod("DoObjectField", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(Rect), typeof(Rect), typeof(int), + typeof(UnityEngine.Object), typeof(Type), typeof(SerializedProperty), validator, typeof(bool), typeof(GUIStyle) }, null); + + DontAllowSceneObjectAttribute dontAllow = field.GetAttribute<DontAllowSceneObjectAttribute>(); ; + + UnityEngine.Object value = (UnityEngine.Object)GetValue(field); + + EditorGUILayout.BeginHorizontal(); + EditorGUI.BeginChangeCheck(); + + Type type = field.Type; + + UnityEngine.Object result = null; + + if (type.IsInterface) + { + Rect position = EditorGUILayout.GetControlRect(false, 16f); + int id = GUIUtility.GetControlID(s_ObjectFieldHash, EditorGUIUtility.native, position); + Delegate validation = Delegate.CreateDelegate(validator, typeof(ObjectEditor).GetMethod("ValidateObjectFieldAssignment", BindingFlags.NonPublic | BindingFlags.Static)); + + result = doObjectField.Invoke(null, new object[] { position, position, id, value, type, null, validation, dontAllow == null, EditorStyles.objectField } ) as UnityEngine.Object; + } + else + result = EditorGUILayout.ObjectField(value, type, dontAllow == null); + + if (EditorGUI.EndChangeCheck()) + field.SetValue(result); + + if (dontAllow == null && (field.Type == typeof(GameObject) || + typeof(Component).IsAssignableFrom(field.Type) || field.Type.IsAssignableFrom(typeof(Component)))) + if (GUILayout.Button(Picker, GUIStyle.none, GUILayout.Width(18), GUILayout.Height(18))) + InspectorEditor.StartPicking(Picked, field); + + EditorGUILayout.EndHorizontal(); + + DrawObjectSelector(field); + } + + private static UnityEngine.Object ValidateObjectFieldAssignment(UnityEngine.Object[] references, Type objType, SerializedProperty property) + { + if (references.Length > 0) + { + if (((references[0] != null) && (references[0].GetType() == typeof(GameObject)))) + { + foreach (UnityEngine.Object obj in ((GameObject)references[0]).GetComponents(typeof(Component))) + { + if ((obj != null) && objType.IsAssignableFrom(obj.GetType())) + { + return obj; + } + } + } + } + + return null; + } + + private void Picked(GameObject go, object tag) + { + InspectorField field = tag as InspectorField; + if (field == null) + return; + + if (field.Type == typeof(GameObject)) + field.SetValue(go); + else if (typeof(Component).IsAssignableFrom(field.Type)) + field.SetValue(go.GetComponent(field.Type)); + } + + public override void OnLabelDoubleClick(InspectorField field) + { + UnityEngine.Object target = field.GetValue() as UnityEngine.Object; + if (target == null) + return; + + if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(target))) + EditorGUIUtility.PingObject(target); + else + { + SceneView view = SceneView.lastActiveSceneView; + Quaternion rotation = view.camera.transform.rotation; + + if (target is GameObject) + SceneView.lastActiveSceneView.LookAt(((GameObject)target).transform.position, rotation, 10); + else if (target is Component) + SceneView.lastActiveSceneView.LookAt(((Component)target).transform.position, rotation, 10); + } + } + + 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 diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ObjectEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ObjectEditor.cs.meta new file mode 100644 index 00000000..b975cbcc --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/ObjectEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1c38d144247c0f9448c0c285b7c255fc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/QuaternionEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/QuaternionEditor.cs new file mode 100644 index 00000000..789ebbb6 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/QuaternionEditor.cs @@ -0,0 +1,168 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class QuaternionEditor : FieldEditor + { + public override bool Expandable + { + get { return false; } + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(Quaternion) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + float width = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = VECTOR_FIELD_WIDTH; + + Quaternion[] values = field.GetValues<Quaternion>(); + if (AdvancedInspectorControl.Level <= InspectorLevel.Advanced) + { + float[] x = new float[values.Length]; + float[] y = new float[values.Length]; + float[] z = new float[values.Length]; + + for (int i = 0; i < values.Length; i++) + { + Vector3 euler = values[i].eulerAngles; + x[i] = euler.x; + y[i] = euler.y; + z[i] = euler.z; + } + + GUILayout.BeginHorizontal(); + + float result; + if (FloatEditor.DrawFloat("X", x, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " X"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Vector3 v = field.GetValue<Quaternion>(field.Instances[i]).eulerAngles; + v.x = result; + field.SetValue(field.Instances[i], Quaternion.Euler(v)); + } + } + + if (FloatEditor.DrawFloat("Y", y, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Y"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Vector3 v = field.GetValue<Quaternion>(field.Instances[i]).eulerAngles; + v.y = result; + field.SetValue(field.Instances[i], Quaternion.Euler(v)); + } + } + + if (FloatEditor.DrawFloat("Z", z, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Z"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Vector3 v = field.GetValue<Quaternion>(field.Instances[i]).eulerAngles; + v.z = result; + field.SetValue(field.Instances[i], Quaternion.Euler(v)); + } + } + + GUILayout.EndHorizontal(); + } + else + { + float[] x = new float[values.Length]; + float[] y = new float[values.Length]; + float[] z = new float[values.Length]; + float[] w = new float[values.Length]; + + for (int i = 0; i < values.Length; i++) + { + x[i] = values[i].x; + y[i] = values[i].y; + z[i] = values[i].z; + w[i] = values[i].w; + } + + GUILayout.BeginHorizontal(); + + float result; + if (FloatEditor.DrawFloat("X", x, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " X"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Quaternion v = field.GetValue<Quaternion>(field.Instances[i]); + v.x = result; + field.SetValue(field.Instances[i], v); + } + } + + if (FloatEditor.DrawFloat("Y", y, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Y"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Quaternion v = field.GetValue<Quaternion>(field.Instances[i]); + v.y = result; + field.SetValue(field.Instances[i], v); + } + } + + GUILayout.EndHorizontal(); + GUILayout.BeginHorizontal(); + + if (FloatEditor.DrawFloat("Z", z, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Z"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Quaternion v = field.GetValue<Quaternion>(field.Instances[i]); + v.z = result; + field.SetValue(field.Instances[i], v); + } + } + + if (FloatEditor.DrawFloat("W", w, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " W"); + + for (int i = 0; i < field.Instances.Length; i++) + { + Quaternion v = field.GetValue<Quaternion>(field.Instances[i]); + v.w = result; + field.SetValue(field.Instances[i], v); + } + } + + GUILayout.EndHorizontal(); + } + + EditorGUIUtility.labelWidth = width; + } + + public override void OnContextualClick(InspectorField field, GenericMenu menu) + { + menu.AddItem(new GUIContent("Identity"), false, Identity); + + menu.AddSeparator(""); + } + + private void Identity() + { + AdvancedInspectorControl.Field.SetValue(Quaternion.identity); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/QuaternionEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/QuaternionEditor.cs.meta new file mode 100644 index 00000000..96defe29 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/QuaternionEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4fd00569d2e889248bedf34a4e50c078 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RangeEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RangeEditor.cs new file mode 100644 index 00000000..0f540c19 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RangeEditor.cs @@ -0,0 +1,109 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class RangeIntEditor : FieldEditor + { + public override Type[] EditedTypes + { + get { return new Type[] { typeof(RangeInt) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + RangeValueAttribute range = field.GetAttribute<RangeValueAttribute>(); + if (range == null) + return; + + EditorGUILayout.BeginHorizontal(); + + RangeInt[] ranges = field.GetValues<RangeInt>(); + + int[] mins = new int[ranges.Length]; + int[] maxs = new int[ranges.Length]; + int min = ranges[0].min; + int max = ranges[0].max; + bool different = false; + + for (int i = 0; i < ranges.Length; i++) + { + mins[i] = ranges[i].min; + maxs[i] = ranges[i].max; + if (ranges[i].min != min || ranges[0].max != max) + different = true; + } + + if (IntegerEditor.DrawInt("", mins, out min, GUILayout.Width(64))) + for (int i = 0; i < field.Instances.Length; i++) + field.SetValue(field.Instances[i], new RangeInt(min, ranges[i].max)); + + EditorGUI.BeginChangeCheck(); + float fMin = min; + float fMax = max; + EditorGUI.showMixedValue = different; + EditorGUILayout.MinMaxSlider(ref fMin, ref fMax, range.Min, range.Max); + if (EditorGUI.EndChangeCheck() && min < max) + for (int i = 0; i < field.Instances.Length; i++) + field.SetValue(field.Instances[i], new RangeInt((int)fMin, (int)fMax)); + + if (IntegerEditor.DrawInt("", maxs, out max, GUILayout.Width(64))) + for (int i = 0; i < field.Instances.Length; i++) + field.SetValue(field.Instances[i], new RangeInt(ranges[i].min, max)); + + EditorGUILayout.EndHorizontal(); + } + } + + public class RangeFloatEditor : FieldEditor + { + public override Type[] EditedTypes + { + get { return new Type[] { typeof(RangeFloat) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + RangeValueAttribute range = field.GetAttribute<RangeValueAttribute>(); + if (range == null) + return; + + EditorGUILayout.BeginHorizontal(); + + RangeFloat[] ranges = field.GetValues<RangeFloat>(); + + float[] mins = new float[ranges.Length]; + float[] maxs = new float[ranges.Length]; + float min = ranges[0].min; + float max = ranges[0].max; + bool different = false; + + for (int i = 0; i < ranges.Length; i++) + { + mins[i] = ranges[i].min; + maxs[i] = ranges[i].max; + if (ranges[i].min != min || ranges[0].max != max) + different = true; + } + + if (FloatEditor.DrawFloat("", mins, out min, GUILayout.Width(64))) + for (int i = 0; i < field.Instances.Length; i++) + field.SetValue(field.Instances[i], new RangeFloat(min, ranges[i].max)); + + EditorGUI.BeginChangeCheck(); + EditorGUI.showMixedValue = different; + EditorGUILayout.MinMaxSlider(ref min, ref max, range.Min, range.Max); + if (EditorGUI.EndChangeCheck() && min < max) + for (int i = 0; i < field.Instances.Length; i++) + field.SetValue(field.Instances[i], new RangeFloat(min, max)); + + if (FloatEditor.DrawFloat("", maxs, out max, GUILayout.Width(64))) + for (int i = 0; i < field.Instances.Length; i++) + field.SetValue(field.Instances[i], new RangeFloat(ranges[i].min, max)); + + EditorGUILayout.EndHorizontal(); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RangeEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RangeEditor.cs.meta new file mode 100644 index 00000000..0701b335 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RangeEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 94080e99d0e3f994a8415cc19062dbde +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RectEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RectEditor.cs new file mode 100644 index 00000000..ee3e61e4 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RectEditor.cs @@ -0,0 +1,165 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class RectEditor : FieldEditor + { + public override bool Expandable + { + get { return false; } + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(Rect), typeof(RectOffset) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + Type type = field.BaseType; + + float labelWidth = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = VECTOR_FIELD_WIDTH; + + if (type == typeof(Rect)) + { + Rect[] values = field.GetValues<Rect>(); + + float[] x = new float[values.Length]; + float[] y = new float[values.Length]; + float[] height = new float[values.Length]; + float[] width = new float[values.Length]; + + for (int i = 0; i < values.Length; i++) + { + x[i] = values[i].x; + y[i] = values[i].y; + height[i] = values[i].height; + width[i] = values[i].width; + } + + GUILayout.BeginHorizontal(); + float result; + if (FloatEditor.DrawFloat("X", x, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " X"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].x = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Y", y, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Y"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].y = result; + field.SetValue(field.Instances[i], values[i]); + } + } + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + if (FloatEditor.DrawFloat("W", width, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Width"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].width = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("H", height, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Height"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].height = result; + field.SetValue(field.Instances[i], values[i]); + } + } + GUILayout.EndHorizontal(); + } + else if (type == typeof(RectOffset)) + { + RectOffset[] values = field.GetValues<RectOffset>(); + + int[] left = new int[values.Length]; + int[] right = new int[values.Length]; + int[] top = new int[values.Length]; + int[] bottom = new int[values.Length]; + + for (int i = 0; i < values.Length; i++) + { + left[i] = values[i].left; + right[i] = values[i].right; + top[i] = values[i].top; + bottom[i] = values[i].bottom; + } + + GUILayout.BeginHorizontal(); + int result; + if (IntegerEditor.DrawInt("L", left, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Left"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].left = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (IntegerEditor.DrawInt("R", right, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Right"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].right = result; + field.SetValue(field.Instances[i], values[i]); + } + } + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + if (IntegerEditor.DrawInt("T", top, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Top"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].top = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (IntegerEditor.DrawInt("B", bottom, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Bottom"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].bottom = result; + field.SetValue(field.Instances[i], values[i]); + } + } + GUILayout.EndHorizontal(); + } + + EditorGUILayout.Space(); + + EditorGUIUtility.labelWidth = labelWidth; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RectEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RectEditor.cs.meta new file mode 100644 index 00000000..aaf7d190 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RectEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fccb35960df296244b543fc8b0adbb98 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraints2DEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraints2DEditor.cs new file mode 100644 index 00000000..4e54cbaa --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraints2DEditor.cs @@ -0,0 +1,60 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class RigidbodyConstraints2DEditor : FieldEditor + { + private const int LABEL_WIDTH = 96; + private const int TOGGLE_WIDTH = 28; + + public override bool EditDerived + { + get { return false; } + } + + public override bool Expandable + { + get { return true; } + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(RigidbodyConstraints2D) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + field.Expandable = true; + if (!field.Expanded) + return; + + EditorGUI.showMixedValue = field.Mixed; + + EditorGUI.BeginChangeCheck(); + + RigidbodyConstraints2D value = (RigidbodyConstraints2D)GetValue(field); + int newValue = 0; + + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("Freeze Position ", GUILayout.Width(LABEL_WIDTH)); + if (GUILayout.Toggle(value.Has(RigidbodyConstraints2D.FreezePositionX), "X", GUILayout.Width(TOGGLE_WIDTH))) + newValue += (int)RigidbodyConstraints2D.FreezePositionX; + + if (GUILayout.Toggle(value.Has(RigidbodyConstraints2D.FreezePositionY), "Y", GUILayout.Width(TOGGLE_WIDTH))) + newValue += (int)RigidbodyConstraints2D.FreezePositionY; + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("Freeze Rotation ", GUILayout.Width(LABEL_WIDTH)); + if (GUILayout.Toggle(value.Has(RigidbodyConstraints2D.FreezeRotation), "Z", GUILayout.Width(TOGGLE_WIDTH))) + newValue += (int)RigidbodyConstraints2D.FreezeRotation; + EditorGUILayout.EndHorizontal(); + + if (EditorGUI.EndChangeCheck()) + field.SetValue(Enum.ToObject(typeof(RigidbodyConstraints2D), newValue)); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraints2DEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraints2DEditor.cs.meta new file mode 100644 index 00000000..7e23526b --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraints2DEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4d2541cd5af63614a837b0ad6801c1ed +timeCreated: 1433909068 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraintsEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraintsEditor.cs new file mode 100644 index 00000000..781c92b8 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraintsEditor.cs @@ -0,0 +1,69 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class RigidbodyConstraintsEditor : FieldEditor + { + private const int LABEL_WIDTH = 96; + private const int TOGGLE_WIDTH = 28; + + public override bool EditDerived + { + get { return false; } + } + + public override bool Expandable + { + get { return true; } + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(RigidbodyConstraints) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + field.Expandable = true; + if (!field.Expanded) + return; + + EditorGUI.showMixedValue = field.Mixed; + + EditorGUI.BeginChangeCheck(); + + RigidbodyConstraints value = (RigidbodyConstraints)GetValue(field); + int newValue = 0; + + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("Freeze Position ", GUILayout.Width(LABEL_WIDTH)); + if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezePositionX), "X", GUILayout.Width(TOGGLE_WIDTH))) + newValue += (int)RigidbodyConstraints.FreezePositionX; + + if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezePositionY), "Y", GUILayout.Width(TOGGLE_WIDTH))) + newValue += (int)RigidbodyConstraints.FreezePositionY; + + if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezePositionZ), "Z", GUILayout.Width(TOGGLE_WIDTH))) + newValue += (int)RigidbodyConstraints.FreezePositionZ; + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + GUILayout.Label("Freeze Rotation ", GUILayout.Width(LABEL_WIDTH)); + if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezeRotationX), "X", GUILayout.Width(TOGGLE_WIDTH))) + newValue += (int)RigidbodyConstraints.FreezeRotationX; + + if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezeRotationY), "Y", GUILayout.Width(TOGGLE_WIDTH))) + newValue += (int)RigidbodyConstraints.FreezeRotationY; + + if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezeRotationZ), "Z", GUILayout.Width(TOGGLE_WIDTH))) + newValue += (int)RigidbodyConstraints.FreezeRotationZ; + EditorGUILayout.EndHorizontal(); + + if (EditorGUI.EndChangeCheck()) + field.SetValue(Enum.ToObject(typeof(RigidbodyConstraints), newValue)); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraintsEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraintsEditor.cs.meta new file mode 100644 index 00000000..1121e382 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/RigidbodyConstraintsEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1aa0c3b940b87d14cbb9705339f378b3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/StringEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/StringEditor.cs new file mode 100644 index 00000000..573450d9 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/StringEditor.cs @@ -0,0 +1,89 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class StringEditor : FieldEditor + { + public override Type[] EditedTypes + { + get { return new Type[] { typeof(string) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + GUILayout.BeginHorizontal(); + + float width = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = 0; + + TextFieldAttribute text = field.GetAttribute<TextFieldAttribute>(); + MultilineAttribute multiline = field.GetAttribute<MultilineAttribute>(); + TextAreaAttribute area = field.GetAttribute<TextAreaAttribute>(); + + object value = GetValue(field); + + EditorGUI.BeginChangeCheck(); + GUIUtility.GetControlID(field.Path.GetHashCode(), FocusType.Passive); + + string result = ""; + if ((text == null && multiline == null && area == null) || (text != null && text.Type == TextFieldType.Standard)) + { + if (style != null) + result = EditorGUILayout.TextField((string)value, style); + else + result = EditorGUILayout.TextField((string)value); + } + else if (multiline != null || area != null || text.Type == TextFieldType.Area) + { + if (style != null) + result = EditorGUILayout.TextArea((string)value, style); + else + result = EditorGUILayout.TextArea((string)value); + } + else if (text.Type == TextFieldType.Password) + { + if (style != null) + result = EditorGUILayout.PasswordField((string)value, style); + else + result = EditorGUILayout.PasswordField((string)value); + } + else if (text.Type == TextFieldType.Tag) + { + if (style != null) + result = EditorGUILayout.TagField((string)value, style); + else + result = EditorGUILayout.TagField((string)value); + } + else if (text.Type == TextFieldType.File) + { + if (GUILayout.Button("...", GUILayout.Height(BUTTON_HEIGHT), GUILayout.Width(BUTTON_HEIGHT * 2))) + result = EditorUtility.OpenFilePanel(text.Title, text.Path, text.Extension); + + if (field.Mixed) + GUILayout.Label("---"); + else + GUILayout.Label((string)value); + } + else if (text.Type == TextFieldType.Folder) + { + if (GUILayout.Button("...", GUILayout.Height(BUTTON_HEIGHT), GUILayout.Width(BUTTON_HEIGHT * 2))) + result = EditorUtility.OpenFolderPanel(text.Title, "", ""); + + if (field.Mixed) + GUILayout.Label("---"); + else + GUILayout.Label((string)value); + } + + if (EditorGUI.EndChangeCheck()) + field.SetValue(result); + + EditorGUIUtility.labelWidth = width; + + GUILayout.EndHorizontal(); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/StringEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/StringEditor.cs.meta new file mode 100644 index 00000000..4154c0d7 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/StringEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 90da81dc74f23b44c85a60181928af9b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/TimeSpanEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/TimeSpanEditor.cs new file mode 100644 index 00000000..fa720ce7 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/TimeSpanEditor.cs @@ -0,0 +1,98 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class TimeSpanEditor : FieldEditor + { + private InspectorField field; + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(TimeSpan) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + int[] days = new int[field.Instances.Length]; + int[] hours = new int[field.Instances.Length]; + int[] mins = new int[field.Instances.Length]; + int[] secs = new int[field.Instances.Length]; + for (int i = 0; i < field.Instances.Length; i++) + { + TimeSpan span = field.GetValue<TimeSpan>(field.Instances[i]); + days[i] = span.Days; + hours[i] = span.Hours; + mins[i] = span.Minutes; + secs[i] = span.Seconds; + } + + float labelWidth = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = 42; + GUILayout.BeginHorizontal(); + + int result; + if (IntegerEditor.DrawInt("Days", days, style, out result)) + { + result = Mathf.Clamp(result, 0, int.MaxValue); + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Days"); + + for (int i = 0; i < field.Instances.Length; i++) + { + TimeSpan span = field.GetValue<TimeSpan>(field.Instances[i]); + span = new TimeSpan(result, span.Hours, span.Minutes, span.Seconds); + field.SetValue(field.Instances[i], span); + } + } + + if (IntegerEditor.DrawInt("Hours", hours, style, out result)) + { + result = Mathf.Clamp(result, 0, int.MaxValue); + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Hours"); + + for (int i = 0; i < field.Instances.Length; i++) + { + TimeSpan span = field.GetValue<TimeSpan>(field.Instances[i]); + span = new TimeSpan(span.Days, result, span.Minutes, span.Seconds); + field.SetValue(field.Instances[i], span); + } + } + + GUILayout.EndHorizontal(); + GUILayout.BeginHorizontal(); + + if (IntegerEditor.DrawInt("Mins", mins, style, out result)) + { + result = Mathf.Clamp(result, 0, int.MaxValue); + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Minutes"); + + for (int i = 0; i < field.Instances.Length; i++) + { + TimeSpan span = field.GetValue<TimeSpan>(field.Instances[i]); + span = new TimeSpan(span.Days, span.Hours, result, span.Seconds); + field.SetValue(field.Instances[i], span); + } + } + + if (IntegerEditor.DrawInt("Secs", secs, style, out result)) + { + result = Mathf.Clamp(result, 0, int.MaxValue); + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Seconds"); + + for (int i = 0; i < field.Instances.Length; i++) + { + TimeSpan span = field.GetValue<TimeSpan>(field.Instances[i]); + span = new TimeSpan(span.Days, span.Hours, span.Minutes, result); + field.SetValue(field.Instances[i], span); + } + } + + GUILayout.EndHorizontal(); + EditorGUILayout.Space(); + + EditorGUIUtility.labelWidth = labelWidth; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/TimeSpanEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/TimeSpanEditor.cs.meta new file mode 100644 index 00000000..e0d700c4 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/TimeSpanEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a8e1b583a89c0f2468b87c50783399f9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/VectorEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/VectorEditor.cs new file mode 100644 index 00000000..00b9bb3e --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/VectorEditor.cs @@ -0,0 +1,208 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections; + +namespace AdvancedInspector +{ + public class VectorEditor : FieldEditor + { + public override bool Expandable + { + get { return false; } + } + + public override Type[] EditedTypes + { + get { return new Type[] { typeof(Vector2), typeof(Vector3), typeof(Vector4) }; } + } + + public override void Draw(InspectorField field, GUIStyle style) + { + Type type = field.BaseType; + + float width = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = VECTOR_FIELD_WIDTH; + + GUILayout.BeginHorizontal(); + if (type == typeof(Vector2)) + { + Vector2[] values = field.GetValues<Vector2>(); + + float[] x = new float[values.Length]; + float[] y = new float[values.Length]; + + for (int i = 0; i < values.Length; i++) + { + x[i] = values[i].x; + y[i] = values[i].y; + } + + float result; + if (FloatEditor.DrawFloat("X", x, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " X"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].x = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Y", y, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Y"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].y = result; + field.SetValue(field.Instances[i], values[i]); + } + } + } + else if (type == typeof(Vector3)) + { + Vector3[] values = field.GetValues<Vector3>(); + + float[] x = new float[values.Length]; + float[] y = new float[values.Length]; + float[] z = new float[values.Length]; + + for (int i = 0; i < values.Length; i++) + { + x[i] = values[i].x; + y[i] = values[i].y; + z[i] = values[i].z; + } + + float result; + if (FloatEditor.DrawFloat("X", x, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " X"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].x = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Y", y, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Y"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].y = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Z", z, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Z"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].z = result; + field.SetValue(field.Instances[i], values[i]); + } + } + } + else if (type == typeof(Vector4)) + { + Vector4[] values = field.GetValues<Vector4>(); + + float[] x = new float[values.Length]; + float[] y = new float[values.Length]; + float[] z = new float[values.Length]; + float[] w = new float[values.Length]; + + for (int i = 0; i < values.Length; i++) + { + x[i] = values[i].x; + y[i] = values[i].y; + z[i] = values[i].z; + w[i] = values[i].w; + } + + float result; + if (FloatEditor.DrawFloat("X", x, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " X"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].x = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Y", y, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Y"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].y = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("Z", z, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " Z"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].z = result; + field.SetValue(field.Instances[i], values[i]); + } + } + + if (FloatEditor.DrawFloat("W", w, style, out result)) + { + Undo.RecordObjects(field.SerializedInstances, "Edit " + field.Name + " W"); + + for (int i = 0; i < field.Instances.Length; i++) + { + values[i].w = result; + field.SetValue(field.Instances[i], values[i]); + } + } + } + GUILayout.EndHorizontal(); + + EditorGUIUtility.labelWidth = width; + } + + public override void OnContextualClick(InspectorField field, GenericMenu menu) + { + menu.AddItem(new GUIContent("Zero"), false, Zero); + menu.AddItem(new GUIContent("One"), false, One); + + menu.AddSeparator(""); + } + + private void Zero() + { + if (AdvancedInspectorControl.Field.Type == typeof(Vector2)) + AdvancedInspectorControl.Field.SetValue(Vector2.zero); + else if (AdvancedInspectorControl.Field.Type == typeof(Vector3)) + AdvancedInspectorControl.Field.SetValue(Vector3.zero); + else if (AdvancedInspectorControl.Field.Type == typeof(Vector4)) + AdvancedInspectorControl.Field.SetValue(Vector4.zero); + } + + private void One() + { + if (AdvancedInspectorControl.Field.Type == typeof(Vector2)) + AdvancedInspectorControl.Field.SetValue(Vector2.one); + else if (AdvancedInspectorControl.Field.Type == typeof(Vector3)) + AdvancedInspectorControl.Field.SetValue(Vector3.one); + else if (AdvancedInspectorControl.Field.Type == typeof(Vector4)) + AdvancedInspectorControl.Field.SetValue(Vector4.one); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/VectorEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/VectorEditor.cs.meta new file mode 100644 index 00000000..79d8e5d8 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/FieldEditors/VectorEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 851a4084094a34f439dc7c658c5343bb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.XML b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.XML new file mode 100644 index 00000000..51610453 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.XML @@ -0,0 +1,453 @@ +<?xml version="1.0"?> +<doc> + <assembly> + <name>UniToolsEditor</name> + </assembly> + <members> + <member name="T:UniToolsEditor.EditorResources"> + <summary> + A strongly-typed resource class, for looking up localized strings, etc. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ResourceManager"> + <summary> + Returns the cached ResourceManager instance used by this class. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Culture"> + <summary> + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Add"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.AlphaOrder"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.AntiAlphaOrder"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Box_Empty"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.BoxFlat"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.BoxFlat_Pro"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.BoxFlat_Title"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.BoxFlat_TitlePro"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.BoxRound"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.BoxRound_Pro"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.BoxRound_Title"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.BoxRound_TitlePro"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Calendar"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Capsule"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Check"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Checkbox_Back_Idle"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Checkbox_Back_Pressed"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Checkbox_Check"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.CheckpointHead"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.CheckpointLine"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.CheckpointPersistant"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ClipBackground"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Connected"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Cross"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Cube"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Cylinder"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Delete"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Directory"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Disconnected"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Drag"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Drag_Light"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Edit"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.EditorBackground"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ExtendBot"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ExtendBotPro"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ExtendTop"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ExtendTopPro"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Favorited"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.File"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.FolderClosed"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.FolderOpen"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Hidden"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Hierarchy"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Hourglass"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Jump"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Knob"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.KnobBack"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Length"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Locked"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Logo"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.MoveDown"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.MoveEmpty"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.MoveUp"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.NoOrder"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.NotFavorited"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Package"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Picker"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.PickerCursor"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.PickerPro"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.PreviewLight1"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.PreviewLight2"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.PreviewLight3"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Refresh"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Save"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.SaveProject"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.SaveScene"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Scene"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ScrollDown"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ScrollLeft"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ScrollLeft_Light"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ScrollRight"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ScrollRight_Light"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.ScrollUp"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.SeparatorHorizontal"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.SeparatorVertical"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Sphere"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Unlocked"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.Visible"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="P:UniToolsEditor.EditorResources.White"> + <summary> + Looks up a localized resource of type System.Byte[]. + </summary> + </member> + <member name="T:UniToolsEditor.Helper"> + <summary> + Collection of static helping method. + </summary> + </member> + <member name="M:UniToolsEditor.Helper.Load(System.String)"> + <summary> + Load a binary file (ex.: from a .resx file) and covert it to a Unity Texture2D + This one is generally used when a non-editor script requires a texture. + It is requested by a the TextureRequest event. + </summary> + <param name="name">The name of the embedded resource.</param> + <returns>A UnityEngine.Texture</returns> + </member> + <member name="M:UniToolsEditor.Helper.Load(System.Byte[])"> + <summary> + Load a binary file (ex.: from a .resx file) and covert it to a Unity Texture2D + </summary> + <param name="binary">The binary resources.</param> + <returns>A UnityEngine.Texture</returns> + </member> + <member name="M:UniToolsEditor.Helper.DrawColor(UnityEngine.Rect,UnityEngine.Color)"> + <summary> + Similar to GUI.DrawTexture, but draw a color instead. + </summary> + <param name="rect">Region to draw.</param> + <param name="color">The color of the draw call.</param> + </member> + <member name="P:UniToolsEditor.Helper.White"> + <summary> + A fully white texture. + Usually used by the DrawColor method. + </summary> + </member> + </members> +</doc> diff --git a/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.XML.meta b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.XML.meta new file mode 100644 index 00000000..9a50f739 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.XML.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 963a7470a10df4e46acea0b0b709948e +TextScriptImporter: + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.dll b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.dll Binary files differnew file mode 100644 index 00000000..93c50a83 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.dll diff --git a/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.dll.meta b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.dll.meta new file mode 100644 index 00000000..9d4c7893 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 45d0940e8e0f52a44876009e88edec75 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.pdb b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.pdb Binary files differnew file mode 100644 index 00000000..09f3307e --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.pdb diff --git a/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.pdb.meta b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.pdb.meta new file mode 100644 index 00000000..ab678cfb --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UniToolsEditor.pdb.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 6c3bf347a80d91c45a5aa19d41a1c61c +DefaultImporter: + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes.meta new file mode 100644 index 00000000..8a5877f3 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: d41f8a83848329147be650112ba92e02 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnchoredJoint2DEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnchoredJoint2DEditor.cs new file mode 100644 index 00000000..af18303f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnchoredJoint2DEditor.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + public class AnchoredJoint2DEditor : Joint2DEditor + { + private const float snapDistance = 0.13f; + private AnchoredJoint2D anchorJoint2D; + + protected override void RefreshFields() + { + base.RefreshFields(); + Type type = typeof(AnchoredJoint2D); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("anchor"), + new DescriptorAttribute("Anchor", "The joint's anchor point on the object that has the joint component.", "http://docs.unity3d.com/ScriptReference/AnchoredJoint2D-anchor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("connectedAnchor"), + new DescriptorAttribute("Connected Anchor", "The joint's anchor point on the second object (ie, the one which doesn't have the joint component).", "http://docs.unity3d.com/ScriptReference/AnchoredJoint2D-connectedAnchor.html"))); + } + + protected override void OnSceneGUI() + { + anchorJoint2D = (AnchoredJoint2D)target; + Vector3 v1 = TransformPoint(anchorJoint2D.transform, anchorJoint2D.anchor); + Vector3 v2 = anchorJoint2D.connectedAnchor; + + if (anchorJoint2D.connectedBody) + v2 = TransformPoint(anchorJoint2D.connectedBody.transform, v2); + + Vector3 v3 = v1 + (v2 - v1).normalized * HandleUtility.GetHandleSize(v1) * 0.1f; + Handles.color = Color.green; + Handles.DrawAAPolyLine(new Vector3[] { v3, v2 }); + + if (HandleAnchor(ref v2, true)) + { + v2 = SnapToSprites(v2); + v2 = SnapToPoint(v2, v1, 0.13f); + if (anchorJoint2D.connectedBody) + v2 = InverseTransformPoint(anchorJoint2D.connectedBody.transform, v2); + + Undo.RecordObject(anchorJoint2D, "Move Connected Anchor"); + anchorJoint2D.connectedAnchor = v2; + } + + if (HandleAnchor(ref v1, false)) + { + v1 = SnapToSprites(v1); + v1 = SnapToPoint(v1, v2, 0.13f); + + Undo.RecordObject(anchorJoint2D, "Move Anchor"); + anchorJoint2D.anchor = InverseTransformPoint(anchorJoint2D.transform, v1); + } + } + + private Vector3 SnapToSprites(Vector3 position) + { + SpriteRenderer component = anchorJoint2D.GetComponent<SpriteRenderer>(); + position = SnapToSprite(component, position, 0.13f); + + if (anchorJoint2D.connectedBody) + { + component = anchorJoint2D.connectedBody.GetComponent<SpriteRenderer>(); + position = SnapToSprite(component, position, 0.13f); + } + + return position; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnchoredJoint2DEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnchoredJoint2DEditor.cs.meta new file mode 100644 index 00000000..e4bfde48 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnchoredJoint2DEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 92274081a60084d499072975be2ef644 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimationEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimationEditor.cs new file mode 100644 index 00000000..6a9783bf --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimationEditor.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(Animation), true)] + public class AnimationEditor : InspectorEditor + { + private static readonly int hash = "AnimationBoundsEditorHash".GetHashCode(); + private object boxEditor; + private MethodInfo edit; + private MethodInfo set; + private Color handleColor = new Color(1, 1, 1, 0.6f); + + protected override void OnEnable() + { + base.OnEnable(); + + Type box = TypeUtility.GetTypeByName("BoxEditor"); + boxEditor = Activator.CreateInstance(box, true, hash); + edit = box.GetMethod("OnSceneGUI", new Type[] { typeof(Transform), typeof(Color), typeof(Vector3).MakeByRefType(), typeof(Vector3).MakeByRefType() }); + set = box.GetMethod("SetAlwaysDisplayHandles"); + } + + protected override void RefreshFields() + { + Type type = typeof(Animation); + if (Instances == null || Instances.Length == 0) + return; + + SerializedObject so = new SerializedObject(Instances.Cast<UnityEngine.Object>().ToArray()); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("clip"), + new DescriptorAttribute("Animation", "The default animation.", "http://docs.unity3d.com/ScriptReference/Animation-clip.html"))); + fields.Add(new InspectorField(type, Instances, so.FindProperty("m_Animations"), + new DescriptorAttribute("Animations", ""))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("playAutomatically"), + new DescriptorAttribute("Play Automatically", "Should the default animation clip (Animation.clip) automatically start playing on startup.", "http://docs.unity3d.com/ScriptReference/Animation-playAutomatically.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("animatePhysics"), + new DescriptorAttribute("Animate Physic", "When turned on, animations will be executed in the physics loop. This is only useful in conjunction with kinematic rigidbodies.", "http://docs.unity3d.com/ScriptReference/Animation-animatePhysics.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("cullingType"), + new DescriptorAttribute("Culling Type", "Controls culling of this Animation component.", "http://docs.unity3d.com/ScriptReference/Animation-cullingType.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("isPlaying"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Is Playing", "Are we playing any animations?", "http://docs.unity3d.com/ScriptReference/Animation-isPlaying.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("localBounds"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Bounds", "AABB of this Animation animation component in local space.", "http://docs.unity3d.com/ScriptReference/Animation-localBounds.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("wrapMode"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Wrap Mode", "How should time beyond the playback range of the clip be treated?", "http://docs.unity3d.com/ScriptReference/Animation-wrapMode.html"))); + + } + + protected override void OnSceneGUI() + { + Animation animation = (Animation)target; + + if ((animation != null) && ((animation.cullingType == AnimationCullingType.BasedOnClipBounds) || (animation.cullingType == AnimationCullingType.BasedOnUserBounds))) + { + set.Invoke(boxEditor, new object[] { animation.cullingType == AnimationCullingType.BasedOnUserBounds }); + Bounds localBounds = animation.localBounds; + Vector3 center = localBounds.center; + Vector3 size = localBounds.size; + + object[] arguments = new object[] { animation.transform, handleColor, center, size }; + + if ((bool)edit.Invoke(boxEditor, arguments)) + { + center = (Vector3)arguments[2]; + size = (Vector3)arguments[3]; + + Undo.RecordObject(animation, "Modified Animation bounds"); + animation.localBounds = new Bounds(center, size); + } + } + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimationEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimationEditor.cs.meta new file mode 100644 index 00000000..2a887671 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimationEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 39152dbad278fc841bed6ccf81404831 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimatorEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimatorEditor.cs new file mode 100644 index 00000000..eabe711c --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimatorEditor.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(Animator), true)] + public class AnimatorEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(Animator); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("runtimeAnimatorController"), new HelpAttribute(new HelpAttribute.HelpDelegate(HelpController)), + new DescriptorAttribute("Controller", "The runtime representation of AnimatorController that controls the Animator.", "http://docs.unity3d.com/ScriptReference/Animator-runtimeAnimatorController.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("avatar"), + new DescriptorAttribute("Avatar", "Gets/Sets the current Avatar.", "http://docs.unity3d.com/ScriptReference/Animator-avatar.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("applyRootMotion"), + new DescriptorAttribute("Apply Root Motion", "Should root motion be applied?", "http://docs.unity3d.com/ScriptReference/Animator-applyRootMotion.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("updateMode"), + new DescriptorAttribute("Update Mode", "Specifies the update mode of the Animator.", "http://docs.unity3d.com/ScriptReference/Animator-updateMode.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("cullingMode"), + new DescriptorAttribute("Culling Mode", "Controls culling of this Animator component.", "http://docs.unity3d.com/ScriptReference/Animator-cullingMode.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("fireEvents"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Fire Events", "If true, the animation track fires their event.", ""))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("logWarnings"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Log Warnings", "Log Animator internal warnings.", ""))); + + InspectorField transform = new InspectorField("Transform"); + + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("speed"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Speed", "The playback speed of the Animator. 1 is normal playback speed.", "http://docs.unity3d.com/ScriptReference/Animator-speed.html"))); + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("bodyPosition"), new InspectAttribute(InspectorLevel.Advanced), new ReadOnlyAttribute(), + new DescriptorAttribute("Body Position", "The position of the body center of mass.", "http://docs.unity3d.com/ScriptReference/Animator-bodyPosition.html"))); + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("rootPosition"), new InspectAttribute(InspectorLevel.Advanced), new ReadOnlyAttribute(), + new DescriptorAttribute("Root Position", "The root position, the position of the game object.", "http://docs.unity3d.com/ScriptReference/Animator-rootPosition.html"))); + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("bodyRotation"), new InspectAttribute(InspectorLevel.Advanced), new ReadOnlyAttribute(), + new DescriptorAttribute("Body Rotation", "The rotation of the body center of mass.", "http://docs.unity3d.com/ScriptReference/Animator-bodyRotation.html"))); + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("rootRotation"), new InspectAttribute(InspectorLevel.Advanced), new ReadOnlyAttribute(), + new DescriptorAttribute("Root Rotation", "The root rotation, the rotation of the game object.", "http://docs.unity3d.com/ScriptReference/Animator-rootRotation.html"))); + + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("targetPosition"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Target Position", "Returns the position of the target specified by SetTarget(AvatarTarget targetIndex, float targetNormalizedTime)).", "http://docs.unity3d.com/ScriptReference/Animator-targetPosition.html"))); + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("targetRotation"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Target Rotation", "Returns the rotation of the target specified by SetTarget(AvatarTarget targetIndex, float targetNormalizedTime)).", "http://docs.unity3d.com/ScriptReference/Animator-targetRotation.html"))); + + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("deltaPosition"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Delta Position", "Gets the avatar delta position for the last evaluated frame.", "http://docs.unity3d.com/ScriptReference/Animator-deltaPosition.html"))); + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("deltaRotation"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Delta Rotation", "Gets the avatar delta rotation for the last evaluated frame.", "http://docs.unity3d.com/ScriptReference/Animator-deltaRotation.html"))); + + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("pivotPosition"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Pivot Position", "Get the current position of the pivot.", "http://docs.unity3d.com/ScriptReference/Animator-pivotPosition.html"))); + transform.Fields.Add(new InspectorField(type, Instances, type.GetProperty("pivotWeight"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Pivot Weight", "Gets the pivot weight.", "http://docs.unity3d.com/ScriptReference/Animator-pivotWeight.html"))); + + InspectorField feet = new InspectorField("Feet"); + + feet.Fields.Add(new InspectorField(type, Instances, type.GetProperty("layersAffectMassCenter"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Layers Affect Mass Center", "", ""))); + feet.Fields.Add(new InspectorField(type, Instances, type.GetProperty("feetPivotActive"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Feet Pivot", "Blends pivot point between body center of mass and feet pivot. At 0%, the blending point is body center of mass. At 100%, the blending point is feet pivot.", "http://docs.unity3d.com/ScriptReference/Animator-feetPivotActive.html"))); + feet.Fields.Add(new InspectorField(type, Instances, type.GetProperty("stabilizeFeet"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Stabilize Feet", "Automatic stabilization of feet during transition and blending.", "http://docs.unity3d.com/ScriptReference/Animator-stabilizeFeet.html"))); + feet.Fields.Add(new InspectorField(type, Instances, type.GetProperty("leftFeetBottomHeight"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Left Feet Bottom Height", "Get left foot bottom height.", "http://docs.unity3d.com/ScriptReference/Animator-leftFeetBottomHeight.html"))); + feet.Fields.Add(new InspectorField(type, Instances, type.GetProperty("rightFeetBottomHeight"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Right Feet Bottom Height", "Get right foot bottom height.", "http://docs.unity3d.com/ScriptReference/Animator-rightFeetBottomHeight.html"))); + + InspectorField debug = new InspectorField("Debug"); + + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("gravityWeight"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Gravity Weight", "The current gravity weight based on current animations that are played.", "http://docs.unity3d.com/ScriptReference/Animator-gravityWeight.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("hasRootMotion"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Has Root Motion", "Returns true if the current rig has root motion.", "http://docs.unity3d.com/ScriptReference/Animator-hasRootMotion.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("hasTransformHierarchy"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Has Tranform Hierarchy", "Returns true if the object has a transform hierarchy.", "http://docs.unity3d.com/ScriptReference/Animator-hasTransformHierarchy.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("humanScale"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Human Scale", "Returns the scale of the current Avatar for a humanoid rig, (1 by default if the rig is generic).", "http://docs.unity3d.com/ScriptReference/Animator-humanScale.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("isHuman"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Is Human", "Returns true if the current rig is humanoid, false if it is generic.", "http://docs.unity3d.com/ScriptReference/Animator-isHuman.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("isMatchingTarget"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Is Matching Target", "If automatic matching is active.", "http://docs.unity3d.com/ScriptReference/Animator-isMatchingTarget.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("isOptimizable"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Is Optimizable", "Returns true if the current rig is optimizable with AnimatorUtility.OptimizeTransformHierarchy.", "http://docs.unity3d.com/ScriptReference/Animator-isOptimizable.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("layerCount"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Layer Count", "The AnimatorController layer count.", "http://docs.unity3d.com/ScriptReference/Animator-layerCount.html"))); + + fields.Add(transform); + fields.Add(feet); + fields.Add(debug); + } + + private HelpAttribute HelpController() + { + foreach (object instance in Instances) + { + Animator animator = instance as Animator; + + if (animator == null) + continue; + + if (animator.runtimeAnimatorController == null) + return new HelpAttribute(HelpType.Error, "The Animator requires a controller to work."); + } + + return null; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimatorEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimatorEditor.cs.meta new file mode 100644 index 00000000..8ca688a1 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/AnimatorEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b9f314ed08707a14daa8524b1f18c511 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/BoxColliderEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/BoxColliderEditor.cs new file mode 100644 index 00000000..99dffeb8 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/BoxColliderEditor.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(BoxCollider), true)] + public class BoxColliderEditor : ColliderEditor + { + private static readonly int hash = "BoxColliderEditor".GetHashCode(); + private object boxEditor; + private MethodInfo edit; + + protected override void OnEnable() + { + base.OnEnable(); + + Type box = TypeUtility.GetTypeByName("BoxEditor"); + boxEditor = Activator.CreateInstance(box, true, hash); + edit = box.GetMethod("OnSceneGUI", new Type[] { typeof(Transform), typeof(Color), typeof(Vector3).MakeByRefType(), typeof(Vector3).MakeByRefType() }); + } + + protected override void RefreshFields() + { + Type type = typeof(BoxCollider); + + base.RefreshFields(); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("center"), + new DescriptorAttribute("Center", "The center of the box, measured in the object's local space.", "http://docs.unity3d.com/ScriptReference/BoxCollider-center.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("size"), + new DescriptorAttribute("Size", "The size of the box, measured in the object's local space.", "http://docs.unity3d.com/ScriptReference/BoxCollider-size.html"))); + } + + protected override void OnSceneGUI() + { + base.OnSceneGUI(); + + if (Event.current.type == EventType.Used) + return; + + BoxCollider boxCollider = (BoxCollider)target; + Vector3 center = boxCollider.center; + Vector3 size = boxCollider.size; + Color color = ColliderHandleColor; + + if (!boxCollider.enabled) + { + color = ColliderHandleColorDisabled; + } + + object[] arguments = new object[] { boxCollider.transform, color, center, size }; + + if ((bool)edit.Invoke(boxEditor, arguments)) + { + center = (Vector3)arguments[2]; + size = (Vector3)arguments[3]; + + Undo.RecordObject(boxCollider, "Modified Box Collider"); + boxCollider.center = center; + boxCollider.size = size; + } + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/BoxColliderEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/BoxColliderEditor.cs.meta new file mode 100644 index 00000000..09c7191b --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/BoxColliderEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f68ddc25c79b9d741b18bac5986fc4f4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CameraEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CameraEditor.cs new file mode 100644 index 00000000..03b2b55b --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CameraEditor.cs @@ -0,0 +1,268 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(Camera), true)] + public class CameraEditor : InspectorEditor + { + private Rect[] rects; + private Camera camera; + + private SceneView view = null; + + public Vector2 screenshotResolution = new Vector2(); + + protected override void RefreshFields() + { + Type type = typeof(Camera); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("clearFlags"), + new DescriptorAttribute("Clear Flag", "How the camera clears the background.", "http://docs.unity3d.com/ScriptReference/Camera-clearFlags.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("backgroundColor"), new InspectAttribute(new InspectAttribute.InspectDelegate(ShowBackground)), + new DescriptorAttribute("Background Color", "The color with which the screen will be cleared.", "http://docs.unity3d.com/ScriptReference/Camera-backgroundColor.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("cullingMask"), new FieldEditorAttribute("LayerMaskEditor"), + new DescriptorAttribute("Culling Mask", "This is used to render parts of the scene selectively.", "http://docs.unity3d.com/ScriptReference/Camera-cullingMask.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("orthographic"), new RestrictAttribute(new RestrictAttribute.RestrictDelegate(Projection)), + new DescriptorAttribute("Orthographic", "Is the camera orthographic (true) or perspective (false)?", "http://docs.unity3d.com/ScriptReference/Camera-orthographic.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("orthographicSize"), new InspectAttribute(new InspectAttribute.InspectDelegate(IsOrthographic)), + new DescriptorAttribute("Size", "Camera's half-size when in orthographic mode.", "http://docs.unity3d.com/ScriptReference/Camera-orthographicSize.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("fieldOfView"), new InspectAttribute(new InspectAttribute.InspectDelegate(IsFieldOfView)), + new RangeValueAttribute(1, 179), new DescriptorAttribute("Field Of View", "The field of view of the camera in degrees.", "http://docs.unity3d.com/ScriptReference/Camera-fieldOfView.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("nearClipPlane"), + new DescriptorAttribute("Near Clip", "The near clipping plane distance.", "http://docs.unity3d.com/ScriptReference/Camera-nearClipPlane.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("farClipPlane"), + new DescriptorAttribute("Far Clip", "The far clipping plane distance.", "http://docs.unity3d.com/ScriptReference/Camera-farClipPlane.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("rect"), + new DescriptorAttribute("Viewport Rect", "Where on the screen is the camera rendered in normalized coordinates.", "http://docs.unity3d.com/ScriptReference/Camera-rect.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("depth"), + new DescriptorAttribute("Depth", "Camera's depth in the camera rendering order.", "http://docs.unity3d.com/ScriptReference/Camera-depth.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("renderingPath"), new HelpAttribute(new HelpAttribute.HelpDelegate(RenderingHelp)), + new DescriptorAttribute("Rendering Path", "Rendering path.", "http://docs.unity3d.com/ScriptReference/Camera-renderingPath.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("targetTexture"), + new DescriptorAttribute("Render Texture", "Destination render texture (Unity Pro only).", "http://docs.unity3d.com/ScriptReference/Camera-targetTexture.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("useOcclusionCulling"), + new DescriptorAttribute("Occlusion Culling", "Whether or not the Camera will use occlusion culling during rendering.", "http://docs.unity3d.com/ScriptReference/Camera-useOcclusionCulling.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("hdr"), new ReadOnlyAttribute(new ReadOnlyAttribute.ReadOnlyDelegate(IsHDRAvailable)), + new DescriptorAttribute("HDR", "High dynamic range rendering.", "http://docs.unity3d.com/ScriptReference/Camera-hdr.html"))); + + fields.Add(new InspectorField(null, new UnityEngine.Object[] { this }, new object[] { this }, this.GetType().GetMethod("TakeScreenshot"), + new Attribute[] { new InspectAttribute(InspectorLevel.Advanced) })); + fields.Add(new InspectorField(null, new UnityEngine.Object[] { this }, new object[] { this }, null, this.GetType().GetField("screenshotResolution"), false, + new Attribute[] { new InspectAttribute(InspectorLevel.Advanced) })); + + // Debug + InspectorField debug = new InspectorField("Debug"); + fields.Add(debug); + + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("aspect"), new InspectAttribute(InspectorLevel.Debug), new ReadOnlyAttribute(), + new DescriptorAttribute("Aspect Ratio", "The aspect ratio (width divided by height).", "http://docs.unity3d.com/ScriptReference/Camera-aspect.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("clearStencilAfterLightingPass"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Clear Stencil After Lighting", "Clear Stencil After Lighting Pass."))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("depthTextureMode"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Depth Texture Mode", "How and if camera generates a depth texture.", "http://docs.unity3d.com/ScriptReference/Camera-depthTextureMode.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("eventMask"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Event Mask", "Mask to select which layers can trigger events on the camera.", "http://docs.unity3d.com/ScriptReference/Camera-eventMask.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("layerCullDistances"), new InspectAttribute(InspectorLevel.Debug), new CollectionAttribute(0), + new DescriptorAttribute("Layer Cull Distances", "Per-layer culling distances.", "http://docs.unity3d.com/ScriptReference/Camera-layerCullDistances.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("layerCullSpherical"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Layer Cull Spherical", "How to perform per-layer culling for a Camera.", "http://docs.unity3d.com/ScriptReference/Camera-layerCullSpherical.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("pixelRect"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Pixel Rect", "Where on the screen is the camera rendered in pixel coordinates.", "http://docs.unity3d.com/ScriptReference/Camera-pixelRect.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("transparencySortMode"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Transparency Sort Mode", "Transparent object sorting mode.", "http://docs.unity3d.com/ScriptReference/Camera-transparencySortMode.html"))); + + if (camera == null) + { + camera = EditorUtility.CreateGameObjectWithHideFlags("Preview Camera", HideFlags.HideAndDontSave, new Type[] { typeof(Camera) }).GetComponent<Camera>(); + camera.enabled = false; + } + + rects = new Rect[Instances.Length]; + + for (int i = 0; i < Instances.Length; i++) + rects[i] = new Rect(25, 25, 0, 0); + } + + protected override void OnSceneGUI() + { + base.OnSceneGUI(); + + if (Event.current.type == EventType.Used) + return; + + if (view != SceneView.currentDrawingSceneView) + InitPosition(SceneView.currentDrawingSceneView); + + Handles.BeginGUI(); + + for (int i = 0; i < Instances.Length; i++) + { + Camera instance = Instances[i] as Camera; + rects[i] = GUILayout.Window(i, rects[i], DrawWindow, instance.name + " Preview"); + } + + Handles.EndGUI(); + } + + public void TakeScreenshot() + { + Camera camera = target as Camera; + if (camera == null) + return; + + RenderTexture texture = RenderTexture.GetTemporary((int)screenshotResolution.x, (int)screenshotResolution.y); + camera.targetTexture = texture; + camera.Render(); + camera.targetTexture = null; + RenderTexture.active = texture; + + Texture2D image = new Texture2D((int)screenshotResolution.x, (int)screenshotResolution.y); + image.ReadPixels(new Rect(0, 0, (int)screenshotResolution.x, (int)screenshotResolution.y), 0, 0); + image.Apply(); + + RenderTexture.ReleaseTemporary(texture); + RenderTexture.active = null; + + byte[] file = image.EncodeToPNG(); + + int count = 1; + string path; + while (true) + { + path = Application.dataPath + "/Screenshot_" + count.ToString() + ".png"; + FileInfo info = new FileInfo(path); + if (!info.Exists) + break; + + count++; + } + + File.WriteAllBytes(path, file); + } + + private void InitPosition(SceneView view) + { + this.view = view; + + int offset = 45; + for (int i = 0; i < Instances.Length; i++) + { + Type gameView = TypeUtility.GetTypeByName("GameView"); + MethodInfo info = gameView.GetMethod("GetSizeOfMainGameView", BindingFlags.Static | BindingFlags.NonPublic); + Vector2 camSize = (Vector2)info.Invoke(null, null); + + int width = (int)(camSize.x * 0.25f); + int height = (int)(camSize.y * 0.25f); + + rects[i] = new Rect(view.position.width - width - 25, view.position.height - height - offset, 0, 0); + offset += height + 35; + } + } + + private void DrawWindow(int i) + { + Rect rect = SceneView.currentDrawingSceneView.camera.pixelRect; + + Camera instance = Instances[i] as Camera; + Type gameView = TypeUtility.GetTypeByName("GameView"); + MethodInfo info = gameView.GetMethod("GetSizeOfMainGameView", BindingFlags.Static | BindingFlags.NonPublic); + Vector2 camSize = (Vector2)info.Invoke(null, null); + + int width = (int)(camSize.x * 0.25f); + int height = (int)(camSize.y * 0.25f); + + camera.CopyFrom(instance); + camera.pixelRect = new Rect(rects[i].x + 5, rect.height - rects[i].y - (height), width, height); + camera.Render(); + GUI.DragWindow(); + GUI.Label(GUILayoutUtility.GetRect(width, height), "", GUIStyle.none); + } + + private IList Projection() + { + List<object> list = new List<object>(); + list.Add(new DescriptorPair(false, new DescriptorAttribute("Perspective", ""))); + list.Add(new DescriptorPair(true, new DescriptorAttribute("Orthographic", ""))); + return list; + } + + private bool ShowBackground() + { + foreach (object instance in Instances) + { + Camera camera = instance as Camera; + + if (camera == null) + continue; + + if (camera.clearFlags == CameraClearFlags.Depth || camera.clearFlags == CameraClearFlags.Nothing) + return false; + } + + return true; + } + + private bool IsOrthographic() + { + foreach (object instance in Instances) + { + Camera camera = instance as Camera; + if (camera == null) + continue; + + if (!camera.orthographic) + return false; + } + + return true; + } + + private bool IsFieldOfView() + { + foreach (object instance in Instances) + { + Camera camera = instance as Camera; + if (camera == null) + continue; + + if (camera.orthographic) + return false; + } + + return true; + } + + private bool IsHDRAvailable() + { + return !UnityEditorInternal.InternalEditorUtility.HasPro(); + } + + private HelpAttribute RenderingHelp() + { + foreach (object instance in Instances) + { + Camera camera = instance as Camera; + if (camera == null) + return null; + + if (camera.renderingPath == RenderingPath.DeferredLighting && !UnityEditorInternal.InternalEditorUtility.HasPro()) + return new HelpAttribute(HelpType.Warning, "Deferred lighting requires Unity Pro."); + } + + return null; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CameraEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CameraEditor.cs.meta new file mode 100644 index 00000000..4aac20f8 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CameraEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5065fd5b555113c46adf4c9bde73b526 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CapsuleColliderEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CapsuleColliderEditor.cs new file mode 100644 index 00000000..cbfd761b --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CapsuleColliderEditor.cs @@ -0,0 +1,165 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(CapsuleCollider), true)] + public class CapsuleColliderEditor : ColliderEditor + { + private int ControlID; + + protected override void RefreshFields() + { + Type type = typeof(CapsuleCollider); + + base.RefreshFields(); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("center"), + new DescriptorAttribute("Center", "The center of the capsule, measured in the object's local space.", "http://docs.unity3d.com/ScriptReference/CapsuleCollider-center.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("height"), + new DescriptorAttribute("Height", "The height of the capsule meased in the object's local space.", "http://docs.unity3d.com/ScriptReference/CapsuleCollider-height.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("radius"), + new DescriptorAttribute("Radius", "The radius of the sphere, measured in the object's local space.", "http://docs.unity3d.com/ScriptReference/CapsuleCollider-radius.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("direction"), new RestrictAttribute(new RestrictAttribute.RestrictDelegate(Direction)), + new DescriptorAttribute("Direction", "The direction of the capsule.", "http://docs.unity3d.com/ScriptReference/CapsuleCollider-direction.html"))); + } + + private List<DescriptorPair> Direction() + { + List<DescriptorPair> list = new List<DescriptorPair>(); + foreach (AxisOrientation orientation in Enum.GetValues(typeof(AxisOrientation))) + list.Add(new DescriptorPair((int)orientation, new DescriptorAttribute(orientation.ToString(), ""))); + + return list; + } + + private Vector3 CapsuleExtends(CapsuleCollider target) + { + return new Vector3(target.radius, target.height, target.radius) + target.center; + } + + private Matrix4x4 CapsuleOrientation(CapsuleCollider target) + { + if (target.direction == (int)AxisOrientation.YAxis) + return Matrix4x4.TRS(target.transform.TransformPoint(target.center), + target.gameObject.transform.rotation, Vector3.one); + else if (target.direction == (int)AxisOrientation.XAxis) + return Matrix4x4.TRS(target.transform.TransformPoint(target.center), + target.transform.rotation * Quaternion.LookRotation(Vector3.up, Vector3.right), Vector3.one); + else + return Matrix4x4.TRS(target.transform.TransformPoint(target.center), + target.transform.rotation * Quaternion.LookRotation(Vector3.right, Vector3.forward), Vector3.one); + } + + protected override void OnSceneGUI() + { + base.OnSceneGUI(); + + if (Event.current.type == EventType.Used) + return; + + CapsuleCollider collider = (CapsuleCollider)target; + + Color color = Handles.color; + if (collider.enabled) + Handles.color = ColliderHandleColor; + else + Handles.color = ColliderHandleColorDisabled; + + bool enabled = GUI.enabled; + if (!Event.current.shift && GUIUtility.hotControl != ControlID) + { + GUI.enabled = false; + Handles.color = new Color(0f, 0f, 0f, 0.001f); + } + + Vector3 capsuleExtents = CapsuleExtends(collider); + Matrix4x4 matrix = CapsuleOrientation(collider); + + float y = capsuleExtents.y - collider.center.y - 1; + float x = capsuleExtents.x - collider.center.x; + + int hotControl = GUIUtility.hotControl; + Vector3 localPos = Vector3.up * y; + + float value = SizeHandle(localPos, Vector3.up, matrix); + if (!GUI.changed) + value = SizeHandle(-localPos, Vector3.down, matrix); + + if (GUI.changed) + collider.height += value / y / collider.height; + + value = SizeHandle(Vector3.left * x, Vector3.left, matrix); + if (!GUI.changed) + value = SizeHandle(-Vector3.left * x, -Vector3.left, matrix); + + if (!GUI.changed) + value = SizeHandle(Vector3.forward * x, Vector3.forward, matrix); + + if (!GUI.changed) + value = SizeHandle(-Vector3.forward * x, -Vector3.forward, matrix); + + if (GUI.changed) + collider.radius += value / Mathf.Max(capsuleExtents.z / collider.radius, capsuleExtents.x / collider.radius); + + if (hotControl != GUIUtility.hotControl && GUIUtility.hotControl != 0) + ControlID = GUIUtility.hotControl; + + if (GUI.changed) + { + Undo.RecordObject(collider, "Edited Capsule Collider"); + collider.radius = Mathf.Max(collider.radius, 0.001f); + collider.height = Mathf.Max(collider.height, 0.001f); + } + + Handles.color = color; + GUI.enabled = enabled; + } + + private float SizeHandle(Vector3 localPos, Vector3 localPullDir, Matrix4x4 matrix) + { + bool changed = GUI.changed; + GUI.changed = false; + + Vector3 rhs = matrix.MultiplyVector(localPullDir); + Vector3 position = matrix.MultiplyPoint(localPos); + float handleSize = HandleUtility.GetHandleSize(position); + + Color color = Handles.color; + float angle = Mathf.Cos(0.7853982f); + + float dot; + if (Camera.current.orthographic) + dot = Vector3.Dot(-Camera.current.transform.forward, rhs); + else + dot = Vector3.Dot((Camera.current.transform.position - position).normalized, rhs); + + if (dot < -angle) + Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * 0.2f); + + Vector3 point = Handles.Slider(position, rhs, handleSize * 0.03f, new Handles.DrawCapFunction(Handles.DotCap), 0f); + + float result = 0f; + if (GUI.changed) + result = HandleUtility.PointOnLineParameter(point, position, rhs); + + GUI.changed |= changed; + Handles.color = color; + + return result; + } + } + + public enum AxisOrientation + { + XAxis = 0, + YAxis = 1, + ZAxis = 2 + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CapsuleColliderEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CapsuleColliderEditor.cs.meta new file mode 100644 index 00000000..f1ab81af --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CapsuleColliderEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c1dcc8846c486e14cb8db81f231d4f59 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterControllerEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterControllerEditor.cs new file mode 100644 index 00000000..6caab9a4 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterControllerEditor.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(CharacterController), true)] + public class CharacterControllerEditor : InspectorEditor + { + private int controlID = -1; + + private Color colliderHandleColor = new Color(145f, 244f, 139f, 210f) / 255f; + private Color colliderHandleColorDisabled = new Color(84f, 200f, 77f, 140f) / 255f; + + protected override void RefreshFields() + { + Type type = typeof(CharacterController); + if (Instances == null || Instances.Length == 0) + return; + + SerializedObject so = new SerializedObject(Instances.Cast<UnityEngine.Object>().ToArray()); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("slopeLimit"), + new DescriptorAttribute("Slope Limit", "The character controllers slope limit in degrees.", "http://docs.unity3d.com/ScriptReference/CharacterController-slopeLimit.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("stepOffset"), + new DescriptorAttribute("Step Offset", "The character controllers step offset in meters.", "http://docs.unity3d.com/ScriptReference/CharacterController-stepOffset.html"))); + fields.Add(new InspectorField(type, Instances, so.FindProperty("m_SkinWidth"), + new DescriptorAttribute("Skin Width", "The thickness of the interpenetration of this capsule.", ""))); + fields.Add(new InspectorField(type, Instances, so.FindProperty("m_MinMoveDistance"), + new DescriptorAttribute("Min Move Distance", "The smallest distance required for the character to move.", ""))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("center"), + new DescriptorAttribute("Center", "The center of the character's capsule relative to the transform's position.", "http://docs.unity3d.com/ScriptReference/CharacterController-center.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("radius"), + new DescriptorAttribute("Radius", "The radius of the character's capsule.", "http://docs.unity3d.com/ScriptReference/CharacterController-radius.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("height"), + new DescriptorAttribute("Height", "The height of the character's capsule.", "http://docs.unity3d.com/ScriptReference/CharacterController-height.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("detectCollisions"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Detect Collisions", "Determines whether other rigidbodies or character controllers collide with this character controller (by default this is always enabled).", "http://docs.unity3d.com/ScriptReference/CharacterController-detectCollisions.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("isGrounded"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Is Grounded", "Was the CharacterController touching the ground during the last move?", "http://docs.unity3d.com/ScriptReference/CharacterController-isGrounded.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("collisionFlags"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Collision Flags", "What part of the capsule collided with the environment during the last CharacterController.Move call.", "http://docs.unity3d.com/ScriptReference/CharacterController-collisionFlags.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("velocity"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Velocity", "The current relative velocity of the Character (see notes).", "http://docs.unity3d.com/ScriptReference/CharacterController-velocity.html"))); + } + + protected override void OnSceneGUI() + { + bool flag = GUIUtility.hotControl == controlID; + + CharacterController controller = (CharacterController)target; + Color color = Handles.color; + + if (controller.enabled) + Handles.color = colliderHandleColor; + else + Handles.color = colliderHandleColorDisabled; + + bool enabled = GUI.enabled; + if (!Event.current.shift && !flag) + { + GUI.enabled = false; + Handles.color = new Color(1f, 0f, 0f, 0.001f); + } + + float height = controller.height * controller.transform.lossyScale.y; + float radius = controller.radius * Mathf.Max(controller.transform.lossyScale.x, controller.transform.lossyScale.z); + + height = Mathf.Max(height, radius * 2f); + + Matrix4x4 matrix = Matrix4x4.TRS(controller.transform.TransformPoint(controller.center), Quaternion.identity, Vector3.one); + Vector3 localPos = (Vector3.up * height) * 0.5f; + + float size = SizeHandle(localPos, Vector3.up, matrix, true); + if (!GUI.changed) + size = SizeHandle(-localPos, Vector3.down, matrix, true); + + size = SizeHandle((Vector3)(Vector3.left * radius), Vector3.left, matrix, true); + if (!GUI.changed) + size = SizeHandle((Vector3)(-Vector3.left * radius), -Vector3.left, matrix, true); + + if (!GUI.changed) + size = SizeHandle((Vector3)(Vector3.forward * radius), Vector3.forward, matrix, true); + + if (!GUI.changed) + size = SizeHandle((Vector3)(-Vector3.forward * radius), -Vector3.forward, matrix, true); + + if (GUI.changed) + { + Undo.RecordObject(controller, "Character Controller Resize"); + + controller.radius += size / (radius / controller.radius); + controller.height += size / (height / controller.height); + + controller.radius = Mathf.Max(controller.radius, 1E-05f); + controller.height = Mathf.Max(controller.height, 1E-05f); + } + + int hotControl = GUIUtility.hotControl; + if ((hotControl != GUIUtility.hotControl) && (GUIUtility.hotControl != 0)) + controlID = GUIUtility.hotControl; + + Handles.color = color; + GUI.enabled = enabled; + } + + private static float SizeHandle(Vector3 localPos, Vector3 localPullDir, Matrix4x4 matrix, bool isEdgeHandle) + { + Vector3 rhs = matrix.MultiplyVector(localPullDir); + Vector3 position = matrix.MultiplyPoint(localPos); + float handleSize = HandleUtility.GetHandleSize(position); + bool changed = GUI.changed; + GUI.changed = false; + Color color = Handles.color; + + float edge = 0f; + if (isEdgeHandle) + edge = Mathf.Cos(0.7853982f); + + float dot; + + if (Camera.current.orthographic) + dot = Vector3.Dot(-Camera.current.transform.forward, rhs); + else + { + Vector3 vector4 = Camera.current.transform.position - position; + dot = Vector3.Dot(vector4.normalized, rhs); + } + + if (dot < -edge) + Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * 0.2f); + + Vector3 point = Handles.Slider(position, rhs, handleSize * 0.03f, new Handles.DrawCapFunction(Handles.DotCap), 0f); + + float distance = 0f; + if (GUI.changed) + distance = HandleUtility.PointOnLineParameter(point, position, rhs); + + GUI.changed |= changed; + Handles.color = color; + return distance; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterControllerEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterControllerEditor.cs.meta new file mode 100644 index 00000000..3a6a95fb --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterControllerEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9fc3a1df54ad5cf4a998c183ab2986a4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterJointEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterJointEditor.cs new file mode 100644 index 00000000..3cf6ad10 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterJointEditor.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(CharacterJoint), true)] + public class CharacterJointEditor : JointEditor + { + protected override void RefreshFields() + { + base.RefreshFields(); + + Type type = typeof(CharacterJoint); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("swingAxis"), + new DescriptorAttribute("Swing Axis", "The secondary axis around which the joint can rotate.", "http://docs.unity3d.com/ScriptReference/CharacterJoint-swingAxis.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("lowTwistLimit"), new ExpandableAttribute(), + new DescriptorAttribute("Low Twist Limit", "The lower limit around the primary axis of the character joint.", "http://docs.unity3d.com/ScriptReference/CharacterJoint-lowTwistLimit.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("highTwistLimit"), new ExpandableAttribute(), + new DescriptorAttribute("High Twist Limit", "The upper limit around the primary axis of the character joint.", "http://docs.unity3d.com/ScriptReference/CharacterJoint-highTwistLimit.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("swing1Limit"), new ExpandableAttribute(), + new DescriptorAttribute("Swing Limit 1", "The limit around the primary axis of the character joint.", "http://docs.unity3d.com/ScriptReference/CharacterJoint-swing1Limit.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("swing2Limit"), new ExpandableAttribute(), + new DescriptorAttribute("Swing Limit 2", "The limit around the primary axis of the character joint.", "http://docs.unity3d.com/ScriptReference/CharacterJoint-swing2Limit.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterJointEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterJointEditor.cs.meta new file mode 100644 index 00000000..625f6dd4 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/CharacterJointEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f8b73519c149ad479e14abd44c0a416 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothEditor.cs new file mode 100644 index 00000000..4935a3a3 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothEditor.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + //[CustomEditor(typeof(Cloth), true)] + public class ClothEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(Cloth); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("bendingStiffness"), + new DescriptorAttribute("Bending Stiffness", "Is the collider a trigger?", "http://docs.unity3d.com/ScriptReference/Collider-isTrigger.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("stretchingStiffness"), + new DescriptorAttribute("Stretching Stiffness", "", ""))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("damping"), + new DescriptorAttribute("Damping", "", ""))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("thickness"), + new DescriptorAttribute("Thickness", "", ""))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("useGravity"), + new DescriptorAttribute("Use Gravity", "", ""))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("selfCollision"), + new DescriptorAttribute("Self Collision", "", ""))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("externalAcceleration"), + new DescriptorAttribute("External Acceleration", "", ""))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("randomAcceleration"), + new DescriptorAttribute("Random Acceleration", "", ""))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothEditor.cs.meta new file mode 100644 index 00000000..2d97e4f0 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ea3b75a7a50b8fd4285dc88b3a1b41f6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothRendererEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothRendererEditor.cs new file mode 100644 index 00000000..a5c4f0a1 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothRendererEditor.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(ClothRenderer), true)] + public class ClothRendererEditor : RendererEditor + { + protected override void RefreshFields() + { + base.RefreshFields(); + Type type = typeof(ClothRenderer); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("pauseWhenNotVisible"), + new DescriptorAttribute("Pause When Not Visible", "Should the cloth simulation be paused when the ClothRenderer is not visible?", "http://docs.unity3d.com/ScriptReference/ClothRenderer-pauseWhenNotVisible.html"))); + } + } +} +#endif
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothRendererEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothRendererEditor.cs.meta new file mode 100644 index 00000000..80e14e84 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ClothRendererEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cd91353f928567e45b9f95d914376353 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ColliderEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ColliderEditor.cs new file mode 100644 index 00000000..93dad847 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ColliderEditor.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + public abstract class ColliderEditor : InspectorEditor + { + public static Color ColliderHandleColor = new Color(0.57f, 0.96f, 0.54f, 0.82f); + public static Color ColliderHandleColorDisabled = new Color(0.33f, 0.78f, 0.3f, 0.55f); + + protected override void RefreshFields() + { + Type type = typeof(Collider); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("isTrigger"), + new DescriptorAttribute("Is Trigger", "Is the collider a trigger?", "http://docs.unity3d.com/ScriptReference/Collider-isTrigger.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("sharedMaterial"), new InspectAttribute(new InspectAttribute.InspectDelegate(IsNotTrigger)), + new DescriptorAttribute("Physic Material", "The shared physic material of this collider.", "http://docs.unity3d.com/ScriptReference/Collider-sharedMaterial.html"))); + } + + private bool IsNotTrigger() + { + for (int i = 0; i < Instances.Length; i++) + { + Collider collider = Instances[i] as Collider; + + if (!collider.isTrigger) + return true; + } + + return false; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ColliderEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ColliderEditor.cs.meta new file mode 100644 index 00000000..06c6b96c --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ColliderEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 164d1d8ffdf5b86498399c42eac1eec2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ConstantForceEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ConstantForceEditor.cs new file mode 100644 index 00000000..aad051da --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ConstantForceEditor.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(ConstantForce), true)] + public class ConstantForceEditor : JointEditor + { + protected override void RefreshFields() + { + Type type = typeof(ConstantForce); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("force"), + new DescriptorAttribute("Force", "The force applied to the rigidbody every frame.", "http://docs.unity3d.com/ScriptReference/ConstantForce-force.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("relativeForce"), + new DescriptorAttribute("Relative Force", "The force - relative to the rigid bodies coordinate system - applied every frame.", "http://docs.unity3d.com/ScriptReference/ConstantForce-relativeForce.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("torque"), + new DescriptorAttribute("Torque", "The torque applied to the rigidbody every frame.", "http://docs.unity3d.com/ScriptReference/ConstantForce-torque.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("relativeTorque"), + new DescriptorAttribute("Relative Torque", "The torque - relative to the rigid bodies coordinate system - applied every frame.", "http://docs.unity3d.com/ScriptReference/ConstantForce-relativeTorque.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ConstantForceEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ConstantForceEditor.cs.meta new file mode 100644 index 00000000..6b847cce --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/ConstantForceEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 67132d5b321335c45ade534dfc5b466e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/FixedJointEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/FixedJointEditor.cs new file mode 100644 index 00000000..753a5da7 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/FixedJointEditor.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(FixedJoint), true)] + public class FixedJointEditor : JointEditor + { + protected override void RefreshFields() + { + base.RefreshFields(); + } + } +} diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/FixedJointEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/FixedJointEditor.cs.meta new file mode 100644 index 00000000..3b953fd9 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/FixedJointEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d710a6940dd6a8469c34b2076d239f6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJoint2DEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJoint2DEditor.cs new file mode 100644 index 00000000..eb23d53f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJoint2DEditor.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(HingeJoint2D), true)] + public class HingeJoint2DEditor : AnchoredJoint2DEditor + { + protected override void RefreshFields() + { + base.RefreshFields(); + Type type = typeof(HingeJoint2D); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("useLimits"), + new DescriptorAttribute("Use Limit", "Should limits be placed on the range of rotation?", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-useLimits.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("limits"), new ExpandableAttribute(), new InspectAttribute(new InspectAttribute.InspectDelegate(UsesLimits)), + new DescriptorAttribute("Limits", "Limit of angular rotation on the joint.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-limits.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("useMotor"), + new DescriptorAttribute("Use Motor", "Should the joint be rotated automatically by a motor torque?", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-useMotor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("motor"), new ExpandableAttribute(), new InspectAttribute(new InspectAttribute.InspectDelegate(UsesMotor)), + new DescriptorAttribute("Motor", "Parameters for the motor force applied to the joint.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-motor.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("jointAngle"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Angle", "The current joint angle with respect to the reference angle.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-jointAngle.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("jointSpeed"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Speed", "The current joint speed.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-jointSpeed.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("limitState"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Limit State", "Gets the state of the joint limit.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-limitState.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("referenceAngle"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Reference Angle", "The angle referenced between the two bodies used as the constraint for the joint.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-referenceAngle.html"))); + } + + private bool UsesLimits() + { + foreach (object instance in Instances) + { + HingeJoint2D hinge = instance as HingeJoint2D; + if (hinge == null) + continue; + + if (hinge.useLimits) + return true; + } + + return false; + } + + private bool UsesMotor() + { + foreach (object instance in Instances) + { + HingeJoint2D hinge = instance as HingeJoint2D; + if (hinge == null) + continue; + + if (hinge.useMotor) + return true; + } + + return false; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJoint2DEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJoint2DEditor.cs.meta new file mode 100644 index 00000000..799d168d --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJoint2DEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a080a881e1bc867428d443b192d7c91a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJointEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJointEditor.cs new file mode 100644 index 00000000..a1c47ee5 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJointEditor.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(HingeJoint), true)] + public class HingeJointEditor : JointEditor + { + protected override void RefreshFields() + { + base.RefreshFields(); + Type type = typeof(HingeJoint); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("useLimits"), + new DescriptorAttribute("Use Limits", "Limit of angular rotation on the joint.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-limits.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("limits"), new ExpandableAttribute(), new InspectAttribute(new InspectAttribute.InspectDelegate(UsesLimits)), + new DescriptorAttribute("Limits", "Should the joint be rotated automatically by a motor torque?", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-useMotor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("useMotor"), + new DescriptorAttribute("Use Motor", "Parameters for the motor force applied to the joint.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-motor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("motor"), new ExpandableAttribute(), new InspectAttribute(new InspectAttribute.InspectDelegate(UsesMotor)), + new DescriptorAttribute("Motor", "Parameters for the motor force applied to the joint.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-motor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("useSpring"), + new DescriptorAttribute("Use Spring", "Parameters for the motor force applied to the joint.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-motor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("spring"), new ExpandableAttribute(), new InspectAttribute(new InspectAttribute.InspectDelegate(UsesSpring)), + new DescriptorAttribute("Spring", "Parameters for the motor force applied to the joint.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-motor.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("angle"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Angle", "Should limits be placed on the range of rotation?", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-useLimits.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("velocity"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Velocity", "The current joint angle with respect to the reference angle.", "http://docs.unity3d.com/ScriptReference/HingeJoint2D-jointAngle.html"))); + } + + private bool UsesLimits() + { + foreach (object instance in Instances) + { + HingeJoint hinge = instance as HingeJoint; + if (hinge == null) + continue; + + if (hinge.useLimits) + return true; + } + + return false; + } + + private bool UsesMotor() + { + foreach (object instance in Instances) + { + HingeJoint hinge = instance as HingeJoint; + if (hinge == null) + continue; + + if (hinge.useMotor) + return true; + } + + return false; + } + + private bool UsesSpring() + { + foreach (object instance in Instances) + { + HingeJoint hinge = instance as HingeJoint; + if (hinge == null) + continue; + + if (hinge.useSpring) + return true; + } + + return false; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJointEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJointEditor.cs.meta new file mode 100644 index 00000000..38d52e78 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/HingeJointEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 908add4326cc5094aad042216c8ffe74 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Joint2DEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Joint2DEditor.cs new file mode 100644 index 00000000..d0df6821 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Joint2DEditor.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + public class Joint2DEditor : InspectorEditor + { + public static GUIStyle anchor = null; + public static GUIStyle anchorActive = null; + public static GUIStyle connectedAnchor = null; + public static GUIStyle connectedAnchorActive = null; + + protected override void RefreshFields() + { + Type type = typeof(Joint2D); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("enableCollision"), + new DescriptorAttribute("Enable Collision", "Should rigid bodies connected with this joint collide?", "http://docs.unity3d.com/ScriptReference/Joint2D-enableCollision.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("connectedBody"), + new DescriptorAttribute("Connected Body", "The Rigidbody2D object to which the other end of the joint is attached (ie, the object without the joint component).", "http://docs.unity3d.com/ScriptReference/Joint2D-connectedBody.html"))); + } + + protected bool HandleAnchor(ref Vector3 position, bool isConnectedAnchor) + { + if (anchor == null) + { + anchor = "U2D.pivotDot"; + anchorActive = "U2D.pivotDotActive"; + connectedAnchor = "U2D.dragDot"; + connectedAnchorActive = "U2D.dragDotActive"; + } + + Handles.DrawCapFunction drawFunc = (!isConnectedAnchor) ? new Handles.DrawCapFunction(AnchorCap) : new Handles.DrawCapFunction(ConnectedAnchorCap); + int id = this.target.GetInstanceID() + ((!isConnectedAnchor) ? 0 : 1); + EditorGUI.BeginChangeCheck(); + position = Handles.Slider2D(id, position, Vector3.back, Vector3.right, Vector3.up, 0f, drawFunc, Vector2.zero); + return EditorGUI.EndChangeCheck(); + } + + public static void AnchorCap(int controlID, Vector3 position, Quaternion rotation, float size) + { + if (controlID == GUIUtility.keyboardControl) + DrawCap(controlID, position, anchorActive); + else + DrawCap(controlID, position, anchor); + } + + public static void ConnectedAnchorCap(int controlID, Vector3 position, Quaternion rotation, float size) + { + if (controlID == GUIUtility.keyboardControl) + DrawCap(controlID, position, connectedAnchorActive); + + else + DrawCap(controlID, position, connectedAnchor); + } + + private static void DrawCap(int controlID, Vector3 position, GUIStyle guiStyle) + { + if (Event.current.type != EventType.Repaint) + { + return; + } + Handles.BeginGUI(); + position = HandleUtility.WorldToGUIPoint(position); + float fixedWidth = guiStyle.fixedWidth; + float fixedHeight = guiStyle.fixedHeight; + Rect position2 = new Rect(position.x - fixedWidth / 2f, position.y - fixedHeight / 2f, fixedWidth, fixedHeight); + guiStyle.Draw(position2, GUIContent.none, controlID); + Handles.EndGUI(); + } + + public static void DrawAALine(Vector3 start, Vector3 end) + { + Handles.DrawAAPolyLine(new Vector3[] { start, end }); + } + + public static void DrawDistanceGizmo(Vector3 anchor, Vector3 connectedAnchor, float distance) + { + Vector3 normalized = (anchor - connectedAnchor).normalized; + Vector3 vector = connectedAnchor + normalized * distance; + Vector3 vector2 = Vector3.Cross(normalized, Vector3.forward); + vector2 *= HandleUtility.GetHandleSize(connectedAnchor) * 0.16f; + Handles.color = Color.green; + DrawAALine(anchor, vector); + DrawAALine(connectedAnchor + vector2, connectedAnchor - vector2); + DrawAALine(vector + vector2, vector - vector2); + } + + private static Matrix4x4 GetAnchorSpaceMatrix(Transform transform) + { + return Matrix4x4.TRS(transform.position, Quaternion.Euler(0f, 0f, transform.rotation.eulerAngles.z), transform.lossyScale); + } + + protected static Vector3 TransformPoint(Transform transform, Vector3 position) + { + return GetAnchorSpaceMatrix(transform).MultiplyPoint(position); + } + + protected static Vector3 InverseTransformPoint(Transform transform, Vector3 position) + { + return GetAnchorSpaceMatrix(transform).inverse.MultiplyPoint(position); + } + + protected static Vector3 SnapToSprite(SpriteRenderer spriteRenderer, Vector3 position, float snapDistance) + { + if (spriteRenderer == null) + return position; + + snapDistance = HandleUtility.GetHandleSize(position) * snapDistance; + float num = spriteRenderer.sprite.bounds.size.x / 2f; + float num2 = spriteRenderer.sprite.bounds.size.y / 2f; + + Vector2[] array = new Vector2[] + { + new Vector2(-num, -num2), + new Vector2(0f, -num2), + new Vector2(num, -num2), + new Vector2(-num, 0f), + new Vector2(0f, 0f), + new Vector2(num, 0f), + new Vector2(-num, num2), + new Vector2(0f, num2), + new Vector2(num, num2) + }; + + Vector2[] array2 = array; + for (int i = 0; i < array2.Length; i++) + { + Vector2 v = array2[i]; + Vector3 vector = spriteRenderer.transform.TransformPoint(v); + if (Vector2.Distance(position, vector) <= snapDistance) + return vector; + } + + return position; + } + + protected static Vector3 SnapToPoint(Vector3 position, Vector3 snapPosition, float snapDistance) + { + snapDistance = HandleUtility.GetHandleSize(position) * snapDistance; + return (Vector3.Distance(position, snapPosition) > snapDistance) ? position : snapPosition; + } + + protected static Vector2 RotateVector2(Vector2 direction, float angle) + { + float f = 0.0174532924f * -angle; + float cos = Mathf.Cos(f); + float sin = Mathf.Sin(f); + float x = direction.x * cos - direction.y * sin; + float y = direction.x * sin + direction.y * cos; + return new Vector2(x, y); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Joint2DEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Joint2DEditor.cs.meta new file mode 100644 index 00000000..8b26bc9f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Joint2DEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 83502c096c3da4e41a24f0c5dd3245e9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/JointEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/JointEditor.cs new file mode 100644 index 00000000..e86c9518 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/JointEditor.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + //[CustomEditor(typeof(Joint), true)] + public class JointEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(Joint); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("connectedBody"), + new DescriptorAttribute("Connected Body", "A reference to another rigidbody this joint connects to.", "http://docs.unity3d.com/ScriptReference/Joint-connectedBody.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("anchor"), + new DescriptorAttribute("Anchor", "The Position of the anchor around which the joints motion is constrained.", "http://docs.unity3d.com/ScriptReference/Joint-anchor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("axis"), + new DescriptorAttribute("Axis", "The Direction of the axis around which the body is constrained.", "http://docs.unity3d.com/ScriptReference/Joint-axis.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("autoConfigureConnectedAnchor"), + new DescriptorAttribute("Auto Configure Anchor", "Should the connectedAnchor be calculated automatically?", "http://docs.unity3d.com/ScriptReference/Joint-autoConfigureConnectedAnchor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("connectedAnchor"), + new DescriptorAttribute("Connected Anchor", "Position of the anchor relative to the connected Rigidbody.", "http://docs.unity3d.com/ScriptReference/Joint-connectedAnchor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("breakForce"), + new DescriptorAttribute("Break Force", "The force that needs to be applied for this joint to break.", "http://docs.unity3d.com/ScriptReference/Joint-breakForce.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("breakTorque"), + new DescriptorAttribute("Break Torque", "The torque that needs to be applied for this joint to break.", "http://docs.unity3d.com/ScriptReference/Joint-breakTorque.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("enableCollision"), + new DescriptorAttribute("Enable Collision", "Enable collision between bodies connected with the joint.", "http://docs.unity3d.com/ScriptReference/Joint-enableCollision.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/JointEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/JointEditor.cs.meta new file mode 100644 index 00000000..410ccaa6 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/JointEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4194aa8c25a02c48951516e3e30ac9a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/LightEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/LightEditor.cs new file mode 100644 index 00000000..b4efe4a2 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/LightEditor.cs @@ -0,0 +1,351 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(Light), true)] + public class LightEditor : InspectorEditor + { + private static Color disabledLightColor = new Color(0.5f, 0.45f, 0.2f, 0.5f); + private static Color lightColor = new Color(0.95f, 0.95f, 0.5f, 0.5f); + + private SerializedProperty m_Lightmapping; + + protected override void RefreshFields() + { + Type type = typeof(Light); + if (Instances == null || Instances.Length == 0) + return; + + SerializedObject so = new SerializedObject(Instances.Cast<UnityEngine.Object>().ToArray()); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("type"), + new HelpAttribute(new HelpAttribute.HelpDelegate(HelpLightType)), + new DescriptorAttribute("Type", "The type of the light.", "http://docs.unity3d.com/ScriptReference/Light-type.html"))); + + m_Lightmapping = so.FindProperty("m_Lightmapping"); + fields.Add(new InspectorField(type, Instances, m_Lightmapping, + new InspectAttribute(new InspectAttribute.InspectDelegate(IsNotArea)), + new RestrictAttribute(new RestrictAttribute.RestrictDelegate(Baking)), + new DescriptorAttribute("Baking", "How the light is handled versus lightmaps."))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("range"), + new InspectAttribute(new InspectAttribute.InspectDelegate(IsPointOrSpot)), + new DescriptorAttribute("Range", "The range of the light.", "http://docs.unity3d.com/ScriptReference/Light-range.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("spotAngle"), + new InspectAttribute(new InspectAttribute.InspectDelegate(IsSpot)), + new DescriptorAttribute("Spot Angle", "The angle of the light's spotlight cone in degrees.", "http://docs.unity3d.com/ScriptReference/Light-spotAngle.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("areaSize"), + new InspectAttribute(new InspectAttribute.InspectDelegate(IsArea)), + new DescriptorAttribute("Area Size", "The size of the area light. Editor only.", "http://docs.unity3d.com/ScriptReference/Light-areaSize.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("color"), + new DescriptorAttribute("Color", "The color of the light.", "http://docs.unity3d.com/ScriptReference/Light-color.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("intensity"), + new RangeValueAttribute(0f, 8f), + new DescriptorAttribute("Intensity", "The Intensity of a light is multiplied with the Light color.", "http://docs.unity3d.com/ScriptReference/Light-intensity.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("bounceIntensity"), + new RangeValueAttribute(0f, 8f), new HelpAttribute(new HelpAttribute.HelpDelegate(HelpBouncedGI)), + new DescriptorAttribute("Bounce Intensity", "The multiplier that defines the strength of the bounce lighting.", "http://docs.unity3d.com/ScriptReference/Light-bounceIntensity.html"))); + + + + //Acts like a group + fields.Add(new InspectorField(type, Instances, type.GetProperty("shadows"), + new InspectAttribute(new InspectAttribute.InspectDelegate(IsNotArea)), + new HelpAttribute(new HelpAttribute.HelpDelegate(HelpShadowPro)), + new DescriptorAttribute("Shadow Type", "How this light casts shadows", "http://docs.unity3d.com/ScriptReference/Light-shadows.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("shadowStrength"), + new InspectAttribute(new InspectAttribute.InspectDelegate(HasShadow)), + new DescriptorAttribute("Strength", "How this light casts shadows.", "http://docs.unity3d.com/ScriptReference/Light-shadowStrength.html"))); + fields.Add(new InspectorField(type, Instances, so.FindProperty("m_Shadows.m_Resolution"), + new InspectAttribute(new InspectAttribute.InspectDelegate(HasShadow)), + new DescriptorAttribute("Resolution", "The shadow's resolution."))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("shadowBias"), + new InspectAttribute(new InspectAttribute.InspectDelegate(HasShadow)), + new DescriptorAttribute("Bias", "Shadow mapping bias.", "http://docs.unity3d.com/ScriptReference/Light-shadowBias.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("shadowNormalBias"), + new InspectAttribute(new InspectAttribute.InspectDelegate(HasShadow)), + new DescriptorAttribute("Normal Bias", "Shadow mapping normal-based bias.", "http://docs.unity3d.com/ScriptReference/Light-shadowNormalBias.html"))); + + fields.Add(new InspectorField(type, Instances, so.FindProperty("m_DrawHalo"), + new DescriptorAttribute("Draw Halo", "Draw a halo around the light. Now work with the Halo class."))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("cookie"), + new DescriptorAttribute("Cookie", "The cookie texture projected by the light.", "http://docs.unity3d.com/ScriptReference/Light-cookie.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("cookieSize"), + new InspectAttribute(new InspectAttribute.InspectDelegate(IsDirectional)), + new DescriptorAttribute("Cookie Size", "The size of a directional light's cookie.", "http://docs.unity3d.com/ScriptReference/Light-cookieSize.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("flare"), + new DescriptorAttribute("Flare", "The flare asset to use for this light.", "http://docs.unity3d.com/ScriptReference/Light-flare.html"))); + + fields.Add(new InspectorField(type, Instances, so.FindProperty("m_RenderMode"), + new DescriptorAttribute("Render Mode", "The rendering path for the lights."))); + + fields.Add(new InspectorField(type, Instances, so.FindProperty("m_CullingMask"), + new HelpAttribute(new HelpAttribute.HelpDelegate(HelpSceneLighting)), + new DescriptorAttribute("Culling Mask", "The object that are affected or ignored by the light."))); + } + + private IList Baking() + { + return new DescriptorPair[] { new DescriptorPair(4, "Realtime", ""), new DescriptorPair(2, "Baked", ""), new DescriptorPair(1, "Mixed", "") }; + } + + public bool IsPointOrSpot() + { + if (IsPoint() || IsSpot()) + return true; + + return false; + } + + public bool IsPoint() + { + return ((Light)Instances[0]).type == LightType.Point; + } + + public bool IsSpot() + { + return ((Light)Instances[0]).type == LightType.Spot; + } + + public bool IsDirectional() + { + return ((Light)Instances[0]).type == LightType.Directional; + } + + public bool IsNotArea() + { + return !IsArea(); + } + + public bool IsArea() + { + return ((Light)Instances[0]).type == LightType.Area; + } + + public bool HasShadow() + { + Light light = (Light)Instances[0]; + return IsNotArea() && (light.shadows == LightShadows.Hard || light.shadows == LightShadows.Soft); + } + + public bool IsSoft() + { + return ((Light)Instances[0]).shadows == LightShadows.Soft; + } + + public bool DoesAnyCameraUseDeferred() + { + Camera[] allCameras = Camera.allCameras; + for (int i = 0; i < allCameras.Length; i++) + if (allCameras[i].actualRenderingPath == RenderingPath.DeferredLighting) + return true; + + return false; + } + + public HelpAttribute HelpBouncedGI() + { + if (((Light)Instances[0]).bounceIntensity > 0 && IsPointOrSpot() && m_Lightmapping.intValue != 2) + return new HelpAttribute(HelpType.Warning, "Currently realtime indirect bounce light shadowing for spot and point lights is not supported."); + + return null; + } + + public HelpAttribute HelpShadowPro() + { + if (HasShadow() && IsPointOrSpot() && !UnityEditorInternal.InternalEditorUtility.HasPro()) + return new HelpAttribute(HelpType.Warning, "Real time shadow for point and spot lights requires Unity Pro."); + + return null; + } + + public HelpAttribute HelpLightType() + { + if (IsArea() && !UnityEditorInternal.InternalEditorUtility.HasPro()) + return new HelpAttribute(HelpType.Warning, "Area lights require Unity Pro."); + + return null; + } + + public HelpAttribute HelpSceneLighting() + { + if (SceneView.currentDrawingSceneView != null && !SceneView.currentDrawingSceneView.m_SceneLighting) + return new HelpAttribute(HelpType.Warning, "One of your scene views has lighting disable, please keep this in mind when editing lighting."); + + return null; + } + + protected override void OnSceneGUI() + { + base.OnSceneGUI(); + + if (Event.current.type == EventType.Used) + return; + + Light light = (Light)target; + Color color = Handles.color; + + if (light.enabled) + Handles.color = lightColor; + else + Handles.color = disabledLightColor; + + float range = light.range; + switch (light.type) + { + case LightType.Spot: + { + Color color2 = Handles.color; + color2.a = Mathf.Clamp01(color.a * 2f); + Handles.color = color2; + Vector2 angleAndRange = new Vector2(light.spotAngle, light.range); + angleAndRange = ConeHandle(light.transform.rotation, light.transform.position, angleAndRange, 1f, 1f, true); + if (GUI.changed) + { + Undo.RecordObject(light, "Adjust Spot Light"); + light.spotAngle = angleAndRange.x; + light.range = Mathf.Max(angleAndRange.y, 0.01f); + } + + break; + } + + case LightType.Point: + { + range = Handles.RadiusHandle(Quaternion.identity, light.transform.position, range, true); + if (GUI.changed) + { + Undo.RecordObject(light, "Adjust Point Light"); + light.range = range; + } + + break; + } + + case LightType.Area: + { + EditorGUI.BeginChangeCheck(); + Vector2 vector2 = RectHandles(light.transform.rotation, light.transform.position, light.areaSize); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(light, "Adjust Area Light"); + light.areaSize = vector2; + } + + break; + } + } + Handles.color = color; + } + + private Vector2 ConeHandle(Quaternion rotation, Vector3 position, Vector2 angleAndRange, float angleScale, float rangeScale, bool handlesOnly) + { + float x = angleAndRange.x; + float y = angleAndRange.y; + float r = y * rangeScale; + + Vector3 forward = rotation * Vector3.forward; + Vector3 up = rotation * Vector3.up; + Vector3 right = rotation * Vector3.right; + + bool changed = GUI.changed; + GUI.changed = false; + r = SizeSlider(position, forward, r); + if (GUI.changed) + y = Mathf.Max(0f, r / rangeScale); + + GUI.changed |= changed; + changed = GUI.changed; + GUI.changed = false; + + float angle = (r * Mathf.Tan((0.01745329f * x) / 2f)) * angleScale; + angle = SizeSlider(position + (forward * r), up, angle); + angle = SizeSlider(position + (forward * r), -up, angle); + angle = SizeSlider(position + (forward * r), right, angle); + angle = SizeSlider(position + (forward * r), -right, angle); + + if (GUI.changed) + x = Mathf.Clamp((57.29578f * Mathf.Atan(angle / (r * angleScale))) * 2f, 0f, 179f); + + GUI.changed |= changed; + if (!handlesOnly) + { + Handles.DrawLine(position, (Vector3)((position + (forward * r)) + (up * angle))); + Handles.DrawLine(position, (Vector3)((position + (forward * r)) - (up * angle))); + Handles.DrawLine(position, (Vector3)((position + (forward * r)) + (right * angle))); + Handles.DrawLine(position, (Vector3)((position + (forward * r)) - (right * angle))); + Handles.DrawWireDisc(position + ((Vector3)(r * forward)), forward, angle); + } + + return new Vector2(x, y); + } + + private Vector2 RectHandles(Quaternion rotation, Vector3 position, Vector2 size) + { + Vector3 forward = (Vector3)(rotation * Vector3.forward); + Vector3 up = (Vector3)(rotation * Vector3.up); + Vector3 right = (Vector3)(rotation * Vector3.right); + + float radiusX = 0.5f * size.x; + float radiusY = 0.5f * size.y; + + Vector3 v1 = (position + (up * radiusY)) + (right * radiusX); + Vector3 v2 = (position - (up * radiusY)) + (right * radiusX); + Vector3 v3 = (position - (up * radiusY)) - (right * radiusX); + Vector3 v4 = (position + (up * radiusY)) - (right * radiusX); + + Handles.DrawLine(v1, v2); + Handles.DrawLine(v2, v3); + Handles.DrawLine(v3, v4); + Handles.DrawLine(v4, v1); + + Color color = Handles.color; + color.a = Mathf.Clamp01(color.a * 2f); + Handles.color = color; + + radiusY = SizeSlider(position, up, radiusY); + radiusY = SizeSlider(position, -up, radiusY); + radiusX = SizeSlider(position, right, radiusX); + radiusX = SizeSlider(position, -right, radiusX); + + if (((Tools.current != Tool.Move) && (Tools.current != Tool.Scale)) || Tools.pivotRotation != PivotRotation.Local) + Handles.DrawLine(position, position + forward); + + size.x = 2f * radiusX; + size.y = 2f * radiusY; + + return size; + } + + private float SizeSlider(Vector3 p, Vector3 direction, float radius) + { + Vector3 position = p + (direction * radius); + float handleSize = HandleUtility.GetHandleSize(position); + + bool changed = GUI.changed; + GUI.changed = false; + + position = Handles.Slider(position, direction, handleSize * 0.03f, new Handles.DrawCapFunction(Handles.DotCap), 0f); + + if (GUI.changed) + radius = Vector3.Dot(position - p, direction); + + GUI.changed |= changed; + return radius; + } + } +} diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/LightEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/LightEditor.cs.meta new file mode 100644 index 00000000..b6532a8e --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/LightEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eebe3cc40d780b84e8af810e11b0d210 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshColliderEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshColliderEditor.cs new file mode 100644 index 00000000..901a3d78 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshColliderEditor.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(MeshCollider), true)] + public class MeshColliderEditor : ColliderEditor + { + protected override void RefreshFields() + { + Type type = typeof(MeshCollider); + + base.RefreshFields(); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("convex"), + new DescriptorAttribute("Convex", "Use a convex collider from the mesh.", "http://docs.unity3d.com/ScriptReference/MeshCollider-convex.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("sharedMesh"), new HelpAttribute(new HelpAttribute.HelpDelegate(HelpMesh)), + new DescriptorAttribute("Mesh", "The mesh object used for collision detection.", "http://docs.unity3d.com/ScriptReference/MeshCollider-sharedMesh.html"))); + } + + private HelpAttribute HelpMesh() + { + foreach (object instance in Instances) + { + MeshCollider collider = instance as MeshCollider; + + if (collider == null) + continue; + + if (collider.sharedMesh == null) + return new HelpAttribute(HelpType.Error, "The Mesh Collider requires a Mesh to work."); + } + + return null; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshColliderEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshColliderEditor.cs.meta new file mode 100644 index 00000000..dabc1f67 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshColliderEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 84ba51c5c587f614e8ebc91d7f72209c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshEditor.cs new file mode 100644 index 00000000..dbc63dc7 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshEditor.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(Mesh), true)] + public class MeshEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(Mesh); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("subMeshCount"), + new DescriptorAttribute("Sub Mesh Count", "The number of submeshes. Every material has a separate triangle list.", "http://docs.unity3d.com/ScriptReference/Mesh-subMeshCount.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("vertices"), + new DescriptorAttribute("Vertices", "Returns a copy of the vertex positions or assigns a new vertex positions array.", "http://docs.unity3d.com/ScriptReference/Mesh-vertices.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("triangles"), + new DescriptorAttribute("Triangles", "An array containing all triangles in the mesh.", "http://docs.unity3d.com/ScriptReference/Mesh-triangles.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("uv"), + new DescriptorAttribute("UV", "The base texture coordinates of the mesh.", "http://docs.unity3d.com/ScriptReference/Mesh-uv.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("uv2"), + new DescriptorAttribute("UV2", "The second texture coordinate set of the mesh, if present.", "http://docs.unity3d.com/ScriptReference/Mesh-uv2.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("uv3"), + new DescriptorAttribute("UV3", "The third texture coordinate set of the mesh, if present.", "http://docs.unity3d.com/ScriptReference/Mesh-uv3.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("uv4"), + new DescriptorAttribute("UV4", "The fourth texture coordinate set of the mesh, if present.", "http://docs.unity3d.com/ScriptReference/Mesh-uv4.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("boneWeights"), + new DescriptorAttribute("Bone Weight", "The bone weights of each vertex.", "http://docs.unity3d.com/ScriptReference/Mesh-boneWeights.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("colors"), + new DescriptorAttribute("Colors", "Vertex colors of the mesh.", "http://docs.unity3d.com/ScriptReference/Mesh-colors.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("normals"), + new DescriptorAttribute("Normals", "The normals of the mesh.", "http://docs.unity3d.com/ScriptReference/Mesh-normals.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("tangents"), + new DescriptorAttribute("Tangents", "The tangents of the mesh.", "http://docs.unity3d.com/ScriptReference/Mesh-tangents.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("bounds"), + new DescriptorAttribute("Bounds", "The bounding volume of the mesh.", "http://docs.unity3d.com/ScriptReference/Mesh-bounds.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshEditor.cs.meta new file mode 100644 index 00000000..5c0453c9 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 01fd2f5ffcf96cb4fbea0525b8abac31 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshFilterEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshFilterEditor.cs new file mode 100644 index 00000000..b74e76a5 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshFilterEditor.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(MeshFilter), true)] + public class MeshFilterEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(MeshFilter); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("sharedMesh"), new ExpandableAttribute(), + new DescriptorAttribute("Mesh", "Returns the shared mesh of the mesh filter.", "http://docs.unity3d.com/ScriptReference/MeshFilter-sharedMesh.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshFilterEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshFilterEditor.cs.meta new file mode 100644 index 00000000..f65f8840 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshFilterEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d593b3a6858817e44a554bfc7b09e8bc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshRendererEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshRendererEditor.cs new file mode 100644 index 00000000..049ff62c --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshRendererEditor.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(MeshRenderer), true)] + public class MeshRendererEditor : RendererEditor + { + protected override void RefreshFields() + { + base.RefreshFields(); + } + } +} diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshRendererEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshRendererEditor.cs.meta new file mode 100644 index 00000000..9864e12f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/MeshRendererEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4c5a0dded0d6c1d4891ba69e2a80bf19 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RendererEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RendererEditor.cs new file mode 100644 index 00000000..08c4ac1c --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RendererEditor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + //[CustomEditor(typeof(Renderer), true)] + public class RendererEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(Renderer); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("shadowCastingMode"), + new DescriptorAttribute("Cast Shadows", "Does this object cast shadows?", "http://docs.unity3d.com/ScriptReference/Renderer-shadowCastingMode.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("receiveShadows"), + new DescriptorAttribute("Receive Shadows", "Does this object receive shadows?", "http://docs.unity3d.com/ScriptReference/Renderer-receiveShadows.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("useLightProbes"), + new DescriptorAttribute("Use Light Probes", "Use light probes for this Renderer.", "http://docs.unity3d.com/ScriptReference/Renderer-useLightProbes.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("probeAnchor"), new InspectAttribute(new InspectAttribute.InspectDelegate(IsUsingLightProbe)), + new DescriptorAttribute("Probes Anchor", "If set, Renderer will use this Transform's position to find the interpolated light probe.", "http://docs.unity3d.com/ScriptReference/Renderer-lightProbeAnchor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("sharedMaterials"), + new DescriptorAttribute("Materials", "All the shared materials of this object.", "http://docs.unity3d.com/ScriptReference/Renderer-sharedMaterials.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("isPartOfStaticBatch"), + new DescriptorAttribute("Static Batched", "Has this renderer been statically batched with any other renderers?", "http://docs.unity3d.com/ScriptReference/Renderer-isPartOfStaticBatch.html"), new InspectAttribute(InspectorLevel.Debug))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("isVisible"), + new DescriptorAttribute("Is Visible", "Is this renderer visible in any camera? (Read Only)", "http://docs.unity3d.com/ScriptReference/Renderer-isVisible.html"), new InspectAttribute(InspectorLevel.Debug))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("lightmapIndex"), + new DescriptorAttribute("Lightmap Index", "The index of the lightmap applied to this renderer.", "http://docs.unity3d.com/ScriptReference/Renderer-lightmapIndex.html"), new InspectAttribute(InspectorLevel.Debug))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("sortingLayerID"), + new DescriptorAttribute("Sorting Layer ID", "ID of the Renderer's sorting layer.", "http://docs.unity3d.com/ScriptReference/Renderer-sortingLayerID.html"), new InspectAttribute(InspectorLevel.Debug))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("sortingLayerName"), + new DescriptorAttribute("Sorting Layer Name", "Name of the Renderer's sorting layer.", "http://docs.unity3d.com/ScriptReference/Renderer-sortingLayerName.html"), new InspectAttribute(InspectorLevel.Debug))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("sortingOrder"), + new DescriptorAttribute("Sorting Order", "Renderer's order within a sorting layer.", "http://docs.unity3d.com/ScriptReference/Renderer-sortingOrder.html"), new InspectAttribute(InspectorLevel.Debug))); + } + + private bool IsUsingLightProbe() + { + for (int i = 0; i < Instances.Length; i++) + if (!((Renderer)Instances[i]).useLightProbes) + return false; + + return true; + } + } +} diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RendererEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RendererEditor.cs.meta new file mode 100644 index 00000000..f2217be6 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RendererEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce4ec5cace74bb249aca3027a18d293a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Rigidbody2DEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Rigidbody2DEditor.cs new file mode 100644 index 00000000..18a5c850 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Rigidbody2DEditor.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(Rigidbody2D), true)] + public class Rigidbody2DEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(Rigidbody2D); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("mass"), + new DescriptorAttribute("Mass", "The mass of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-mass.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("drag"), + new DescriptorAttribute("Linear Drag", "Coefficient of drag.", "http://docs.unity3d.com/ScriptReference/Rigidbody2D-drag.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("angularDrag"), + new DescriptorAttribute("Angular Drag", "Coefficient of angular drag.", "http://docs.unity3d.com/ScriptReference/Rigidbody2D-angularDrag.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("gravityScale"), + new DescriptorAttribute("Gravity Scale", "The degree to which this object is affected by gravity.", "http://docs.unity3d.com/ScriptReference/Rigidbody2D-gravityScale.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("isKinematic"), + new DescriptorAttribute("Is Kinematic", "Should this rigidbody be taken out of physics control?", "http://docs.unity3d.com/ScriptReference/Rigidbody2D-isKinematic.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("interpolation"), + new DescriptorAttribute("Interpolation", "Physics interpolation used between updates.", "http://docs.unity3d.com/ScriptReference/Rigidbody2D-interpolation.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("sleepMode"), + new DescriptorAttribute("Sleep Mode", "The sleep state that the rigidbody will initially be in.", "http://docs.unity3d.com/ScriptReference/Rigidbody2D-sleepMode.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("collisionDetectionMode"), + new DescriptorAttribute("Collision Detection", "The method used by the physics engine to check if two objects have collided.", "http://docs.unity3d.com/ScriptReference/Rigidbody2D-collisionDetectionMode.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("constraints"), + new DescriptorAttribute("Constraints", "Controls which degrees of freedom are allowed for the simulation of this Rigidbody2D.", "http://docs.unity3d.com/ScriptReference/Rigidbody2D-constraints.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("velocity"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Velocity", "Linear velocity of the rigidbody.", "http://docs.unity3d.com/ScriptReference/Rigidbody2D-velocity.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Rigidbody2DEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Rigidbody2DEditor.cs.meta new file mode 100644 index 00000000..f12a6d7c --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/Rigidbody2DEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d0bb3c1cf8af559429a6595132875d69 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RigidbodyEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RigidbodyEditor.cs new file mode 100644 index 00000000..c2d95781 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RigidbodyEditor.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(Rigidbody), true)] + public class RigidbodyEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(Rigidbody); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("mass"), + new DescriptorAttribute("Mass", "The mass of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-mass.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("drag"), + new DescriptorAttribute("Drag", "The drag of the object", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-drag.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("angularDrag"), + new DescriptorAttribute("Angular Drag", "The angular drag of the object", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-angularDrag.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("useGravity"), + new DescriptorAttribute("Use Gravity", "Is the object affected by world gravity", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-useGravity.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("isKinematic"), + new DescriptorAttribute("Is Kinematic", "If true, physic does not drive this object, used for animation", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-isKinematic.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("interpolation"), + new DescriptorAttribute("Interpolation", "Interpolation allows you to smooth out the effect of running physics at a fixed frame rate", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-interpolation.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("collisionDetectionMode"), + new DescriptorAttribute("Collision Detection", "How collision are detected", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-collisionDetectionMode.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("constraints"), new EnumAttribute(true), + new DescriptorAttribute("Constraints", "Controls which degrees of freedom are allowed for the simulation of this Rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-constraints.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("centerOfMass"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Center of Mass", "In essence, the pivot around which the object spins", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-centerOfMass.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("freezeRotation"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Freeze Rotation", "Controls whether physics will change the rotation of the object", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-freezeRotation.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("inertiaTensor"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Inertia Tensor", "The diagonal inertia tensor of mass relative to the center of mass", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-inertiaTensor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("inertiaTensorRotation"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Inertia Tensor Rotation", "The rotation of the inertia tensor", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-inertiaTensorRotation.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("maxAngularVelocity"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Max Angular Velocity", "The maximimum angular velocity of the rigidbody. (Default 7) range { 0, infinity }", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-maxAngularVelocity.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("sleepThreshold"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Sleep Threshold", "The mass-normalized energy threshold, below which objects start going to sleep.", "http://docs.unity3d.com/ScriptReference/Rigidbody-sleepThreshold.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("solverIterationCount"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Solver Iteration Count", "Allows you to override the solver iteration count per rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-solverIterationCount.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("useConeFriction"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Use Cone Friction", "Force cone friction to be used for this rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-useConeFriction.html"))); + + InspectorField debug = new InspectorField("Debug"); + fields.Add(debug); + + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("position"), new ReadOnlyAttribute(), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Position", "The position of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-position.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("rotation"), new ReadOnlyAttribute(), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Rotation", "The rotation of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-rotation.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("velocity"), new ReadOnlyAttribute(), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Velocity", "The velocity of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-velocity.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("angularVelocity"), new ReadOnlyAttribute(), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("Angular Velocity", "The rotation velocity of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-angularVelocity.html"))); + debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("worldCenterOfMass"), new InspectAttribute(InspectorLevel.Debug), + new DescriptorAttribute("World Center of Mass", "The center of mass of the rigidbody in world space", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-worldCenterOfMass.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RigidbodyEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RigidbodyEditor.cs.meta new file mode 100644 index 00000000..be1230bf --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/RigidbodyEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d67a22510eb1e240abe8ebec8839fa4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SkinnedMeshRendererEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SkinnedMeshRendererEditor.cs new file mode 100644 index 00000000..a030be92 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SkinnedMeshRendererEditor.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(SkinnedMeshRenderer), true)] + public class SkinnedMeshRendererEditor : RendererEditor + { + protected override void RefreshFields() + { + base.RefreshFields(); + Type type = typeof(SkinnedMeshRenderer); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("quality"), + new DescriptorAttribute("Quality", "The maximum number of bones affecting a single vertex.", "http://docs.unity3d.com/ScriptReference/SkinnedMeshRenderer-quality.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("updateWhenOffscreen"), + new DescriptorAttribute("Update Off Screen", "If enabled, the Skinned Mesh will be updated when offscreen. If disabled, this also disables updating animations.", "http://docs.unity3d.com/ScriptReference/SkinnedMeshRenderer-updateWhenOffscreen.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("sharedMesh"), + new DescriptorAttribute("Mesh", "The mesh used for skinning.", "http://docs.unity3d.com/ScriptReference/SkinnedMeshRenderer-sharedMesh.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("rootBone"), + new DescriptorAttribute("Root", "The root boot of the skeletton hierarchy."))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("bones"), + new CollectionAttribute(-1), new DescriptorAttribute("Bones", "The bones used to skin the mesh.", "http://docs.unity3d.com/ScriptReference/SkinnedMeshRenderer-bones.html"), new InspectAttribute(InspectorLevel.Advanced))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("localBounds"), + new DescriptorAttribute("Bounds", "AABB of this Skinned Mesh in its local space.", "http://docs.unity3d.com/ScriptReference/SkinnedMeshRenderer-localBounds.html"), new InspectAttribute(InspectorLevel.Advanced))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SkinnedMeshRendererEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SkinnedMeshRendererEditor.cs.meta new file mode 100644 index 00000000..b8af0844 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SkinnedMeshRendererEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e89a2246ecd24504bafbbe834d56c265 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SphereColliderEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SphereColliderEditor.cs new file mode 100644 index 00000000..16f0b519 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SphereColliderEditor.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(SphereCollider), true)] + public class SphereColliderEditor : ColliderEditor + { + private int ControlID = -1; + + protected override void RefreshFields() + { + Type type = typeof(SphereCollider); + + base.RefreshFields(); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("center"), + new DescriptorAttribute("Center", "The center of the sphere, measured in the object's local space.", "http://docs.unity3d.com/ScriptReference/SphereCollider-center.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("radius"), + new DescriptorAttribute("Radius", "The radius of the sphere, measured in the object's local space.", "http://docs.unity3d.com/ScriptReference/SphereCollider-radius.html"))); + } + + protected override void OnSceneGUI() + { + base.OnSceneGUI(); + + if (Event.current.type == EventType.Used) + return; + + SphereCollider collider = (SphereCollider)target; + Color color = Handles.color; + + if (collider.enabled) + Handles.color = ColliderHandleColor; + else + Handles.color = ColliderHandleColorDisabled; + + bool enabled = GUI.enabled; + if (!Event.current.shift && GUIUtility.hotControl != ControlID) + { + GUI.enabled = false; + Handles.color = new Color(0f, 0f, 0f, 0.001f); + } + + Vector3 lossyScale = collider.transform.lossyScale; + float x = Mathf.Abs(lossyScale.x); + + float scale = Mathf.Max(Mathf.Max(x, Mathf.Abs(lossyScale.y)), Mathf.Abs(lossyScale.z)); + float radius = Mathf.Max(Mathf.Abs(scale * collider.radius), 0.001f); + + Vector3 position = collider.transform.TransformPoint(collider.center); + Quaternion rotation = collider.transform.rotation; + + int hotControl = GUIUtility.hotControl; + float value = Handles.RadiusHandle(rotation, position, radius, true); + + if (GUI.changed) + { + Undo.RecordObject(collider, "Edited Sphere Collider"); + collider.radius = value / scale; + } + + if (hotControl != GUIUtility.hotControl && GUIUtility.hotControl != 0) + ControlID = GUIUtility.hotControl; + + Handles.color = color; + GUI.enabled = enabled; + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SphereColliderEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SphereColliderEditor.cs.meta new file mode 100644 index 00000000..ecfce56a --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SphereColliderEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c593d1bebd359cc4c8a9ab8af4ab926d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJoint2DEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJoint2DEditor.cs new file mode 100644 index 00000000..c297b985 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJoint2DEditor.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(SpringJoint2D), true)] + public class SpringJoint2DEditor : AnchoredJoint2DEditor + { + protected override void RefreshFields() + { + base.RefreshFields(); + Type type = typeof(SpringJoint2D); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("dampingRatio"), + new DescriptorAttribute("Damping Ratio", "The amount by which the spring force is reduced in proportion to the movement speed.", "http://docs.unity3d.com/ScriptReference/SpringJoint2D-dampingRatio.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("distance"), + new DescriptorAttribute("Distance", "The distance the spring will try to keep between the two objects.", "http://docs.unity3d.com/ScriptReference/SpringJoint2D-distance.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("frequency"), + new DescriptorAttribute("Frequency", "The frequency at which the spring oscillates around the distance distance between the objects.", "http://docs.unity3d.com/ScriptReference/SpringJoint2D-frequency.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJoint2DEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJoint2DEditor.cs.meta new file mode 100644 index 00000000..7b6300b5 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJoint2DEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d4b19f118a5c41a43b3069f11a4c8490 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJointEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJointEditor.cs new file mode 100644 index 00000000..445095ed --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJointEditor.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(SpringJoint), true)] + public class SpringJointEditor : JointEditor + { + protected override void RefreshFields() + { + base.RefreshFields(); + Type type = typeof(SpringJoint); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("damper"), + new DescriptorAttribute("Damper", "The damper force used to dampen the spring force.", "http://docs.unity3d.com/ScriptReference/SpringJoint-damper.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("spring"), + new DescriptorAttribute("Spring", "The spring force used to keep the two objects together.", "http://docs.unity3d.com/ScriptReference/SpringJoint-spring.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("minDistance"), + new DescriptorAttribute("Minimum Distance", "The minimum distance between the bodies relative to their initial distance.", "http://docs.unity3d.com/ScriptReference/SpringJoint-minDistance.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("maxDistance"), + new DescriptorAttribute("Maximum Distance", "The maximum distance between the bodies relative to their initial distance.", "http://docs.unity3d.com/ScriptReference/SpringJoint-maxDistance.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJointEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJointEditor.cs.meta new file mode 100644 index 00000000..89f200fd --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpringJointEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ef55a4c43739280438783fe3c0648c60 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpriteRendererEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpriteRendererEditor.cs new file mode 100644 index 00000000..6ee4f9ee --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpriteRendererEditor.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + //Under construction. Unity's editor has multiple internal method and classes used for this editor. + /*[CanEditMultipleObjects] + //[CustomEditor(typeof(SpriteRenderer), true)] + public class SpriteRendererEditor : RendererEditor + { + protected override void RefreshFields() + { + Type type = typeof(SpriteRenderer); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("subMeshCount"), + new DescriptorAttribute("Sub Mesh Count", "The number of submesh this mesh has."))); + } + + private void IsMaterialUsingFixedFunction(out bool vertex, out bool fragment) + { + vertex = false; + fragment = false; + Material sharedMaterial = (base.target as SpriteRenderer).sharedMaterial; + if (sharedMaterial != null) + { + vertex = ShaderUtil.GetVertexModel(sharedMaterial.shader) == ShaderUtil.ShaderModel.None; + fragment = ShaderUtil.GetFragmentModel(sharedMaterial.shader) == ShaderUtil.ShaderModel.None; + } + } + }*/ +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpriteRendererEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpriteRendererEditor.cs.meta new file mode 100644 index 00000000..23399f70 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SpriteRendererEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1e7e1c25afd649e429c7ebc946213e1b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes.meta new file mode 100644 index 00000000..65799e90 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 17d10043e438a1b4a957506dd467ac9d +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointAngleLimits2D.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointAngleLimits2D.cs new file mode 100644 index 00000000..ee057444 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointAngleLimits2D.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(JointAngleLimits2D), true)] + public class JointAngleLimits2DEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(JointAngleLimits2D); + + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("min"), + new DescriptorAttribute("Lower Angle", "Lower angular limit of rotation.", "http://docs.unity3d.com/ScriptReference/JointAngleLimits2D-min.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("max"), + new DescriptorAttribute("Upper Angle", "Upper angular limit of rotation.", "http://docs.unity3d.com/ScriptReference/JointAngleLimits2D-max.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointAngleLimits2D.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointAngleLimits2D.cs.meta new file mode 100644 index 00000000..da5932a3 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointAngleLimits2D.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1931b05fa3c73e043b6c0808c650582e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointDriveEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointDriveEditor.cs new file mode 100644 index 00000000..99b097d2 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointDriveEditor.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(JointDrive), true)] + public class JointDriveEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(JointDrive); + + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("maximumForce"), + new DescriptorAttribute("Maximum Force", "Amount of force applied to push the object toward the defined direction.", "http://docs.unity3d.com/ScriptReference/JointDrive-maximumForce.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("mode"), + new DescriptorAttribute("Mode", "Whether the drive should attempt to reach position, velocity, both or nothing.", "http://docs.unity3d.com/ScriptReference/JointDrive-mode.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("positionDamper"), + new DescriptorAttribute("Position Damper", "Resistance strength against the Position Spring. Only used if mode includes Position.", "http://docs.unity3d.com/ScriptReference/JointDrive-positionDamper.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("positionSpring"), + new DescriptorAttribute("Position Spring", "Strength of a rubber-band pull toward the defined direction. Only used if mode includes Position.", "http://docs.unity3d.com/ScriptReference/JointDrive-positionSpring.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointDriveEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointDriveEditor.cs.meta new file mode 100644 index 00000000..b7aeab71 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointDriveEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ecf97e5de8d75dc48abf82579a240c2b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointLimitsEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointLimitsEditor.cs new file mode 100644 index 00000000..834679eb --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointLimitsEditor.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(JointLimits), true)] + public class JointLimitsEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(JointLimits); + + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("min"), + new DescriptorAttribute("Minimum", "The lower limit of the joint.", "http://docs.unity3d.com/ScriptReference/JointLimits-min.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("minBounce"), + new DescriptorAttribute("Minimum Bounce", "The bounciness of the joint when hitting the lower limit of the joint.", "http://docs.unity3d.com/ScriptReference/JointLimits-minBounce.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("max"), + new DescriptorAttribute("Maximum", "The upper limit of the joint.", "http://docs.unity3d.com/ScriptReference/JointLimits-max.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("maxBounce"), + new DescriptorAttribute("Maximum Bounce", "The bounciness of the joint when hitting the upper limit of the joint.", "http://docs.unity3d.com/ScriptReference/JointLimits-maxBounce.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointLimitsEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointLimitsEditor.cs.meta new file mode 100644 index 00000000..3a19c9c0 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointLimitsEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6604bae731e21cc428c2af5fe4345816 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotor2DEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotor2DEditor.cs new file mode 100644 index 00000000..7878455f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotor2DEditor.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(JointMotor2D), true)] + public class JointMotor2DEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(JointMotor2D); + + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("maxMotorTorque"), + new DescriptorAttribute("Maximum Motor Torque", "The maximum force that can be applied to the Rigidbody2D at the joint to attain the target speed.", "http://docs.unity3d.com/ScriptReference/JointMotor2D-maxMotorTorque.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("motorSpeed"), + new DescriptorAttribute("Motor Speed", "The desired speed for the Rigidbody2D to reach as it moves with the joint.", "http://docs.unity3d.com/ScriptReference/JointMotor2D-motorSpeed.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotor2DEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotor2DEditor.cs.meta new file mode 100644 index 00000000..5cd76dec --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotor2DEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: df584c85589b426428f18a1db8819468 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotorEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotorEditor.cs new file mode 100644 index 00000000..aa08051f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotorEditor.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(JointMotor), true)] + public class JointMotorEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(JointMotor); + + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("force"), + new DescriptorAttribute("Force", "The motor will apply a force.", "http://docs.unity3d.com/ScriptReference/JointMotor-force.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("freeSpin"), + new DescriptorAttribute("Free Spin", "If freeSpin is enabled the motor will only accelerate but never slow down.", "http://docs.unity3d.com/ScriptReference/JointMotor-freeSpin.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("targetVelocity"), + new DescriptorAttribute("Target Velocity", "The motor will apply a force up to force to achieve targetVelocity.", "http://docs.unity3d.com/ScriptReference/JointMotor-targetVelocity.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotorEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotorEditor.cs.meta new file mode 100644 index 00000000..9d3377d6 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointMotorEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: edad1525ab08563449869286171570fe +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointSpringEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointSpringEditor.cs new file mode 100644 index 00000000..925489e4 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointSpringEditor.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(JointSpring), true)] + public class JointSpringEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(JointSpring); + + fields.Add(new InspectorField(parent, type, Instances, type.GetField("damper"), + new DescriptorAttribute("Damper", "The damper force uses to dampen the spring.", "http://docs.unity3d.com/ScriptReference/JointSpring-damper.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetField("spring"), + new DescriptorAttribute("Spring", "The spring forces used to reach the target position.", "http://docs.unity3d.com/ScriptReference/JointSpring-spring.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetField("targetPosition"), + new DescriptorAttribute("Target Position", "The target position the joint attempts to reach.", "http://docs.unity3d.com/ScriptReference/JointSpring-targetPosition.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointSpringEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointSpringEditor.cs.meta new file mode 100644 index 00000000..22e7faa5 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/JointSpringEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 78cd38f97873b494696f3b39efb6be6b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/SoftJointLimitEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/SoftJointLimitEditor.cs new file mode 100644 index 00000000..216b85ae --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/SoftJointLimitEditor.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(SoftJointLimit), true)] + public class SoftJointLimitEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(SoftJointLimit); + + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("bounciness"), + new DescriptorAttribute("Bounciness", "When the joint hits the limit, it can be made to bounce off it.", "http://docs.unity3d.com/ScriptReference/SoftJointLimit-bounciness.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("damper"), + new DescriptorAttribute("Damper", "If spring is greater than zero, the limit is soft.", "http://docs.unity3d.com/ScriptReference/SoftJointLimit-damper.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("limit"), + new DescriptorAttribute("Limit", "The limit position/angle of the joint.", "http://docs.unity3d.com/ScriptReference/SoftJointLimit-limit.html"))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("spring"), + new DescriptorAttribute("Spring", "If greater than zero, the limit is soft. The spring will pull the joint back.", "http://docs.unity3d.com/ScriptReference/SoftJointLimit-spring.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/SoftJointLimitEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/SoftJointLimitEditor.cs.meta new file mode 100644 index 00000000..b87ed17f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/SoftJointLimitEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 394fe629fc2ed3344b6393d22fd84d6e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/WheelFrictionCurveEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/WheelFrictionCurveEditor.cs new file mode 100644 index 00000000..7fefbdf9 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/WheelFrictionCurveEditor.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(WheelFrictionCurve), true)] + public class WheelFrictionCurveEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(WheelFrictionCurve); + + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("extremumSlip"), + new DescriptorAttribute("Extremum Slip", ""))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("extremumValue"), + new DescriptorAttribute("Extremum Value", ""))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("asymptoteSlip"), + new DescriptorAttribute("Asymptote Slip", ""))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("asymptoteValue"), + new DescriptorAttribute("Asymptote Value", ""))); + fields.Add(new InspectorField(parent, type, Instances, type.GetProperty("stiffness"), + new DescriptorAttribute("Stiffness", ""))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/WheelFrictionCurveEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/WheelFrictionCurveEditor.cs.meta new file mode 100644 index 00000000..a0590680 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/SubTypes/WheelFrictionCurveEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 88effe38dc3d6ed46a367906af5bc842 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TerrainColliderEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TerrainColliderEditor.cs new file mode 100644 index 00000000..d2c41a48 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TerrainColliderEditor.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(TerrainCollider), true)] + public class TerrainColliderEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(TerrainCollider); + if (Instances == null || Instances.Length == 0) + return; + + SerializedObject so = new SerializedObject(Instances.Cast<UnityEngine.Object>().ToArray()); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("isTrigger"), + new DescriptorAttribute("Is Trigger", "Is the collider a trigger?", "http://docs.unity3d.com/ScriptReference/Collider-isTrigger.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("terrainData"), + new DescriptorAttribute("Terrain Data", "The terrain that stores the heightmap.", "http://docs.unity3d.com/ScriptReference/TerrainCollider-terrainData.html"))); + fields.Add(new InspectorField(type, Instances, so.FindProperty("m_EnableTreeColliders"), + new DescriptorAttribute("Create Tree Colliders", "", ""))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TerrainColliderEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TerrainColliderEditor.cs.meta new file mode 100644 index 00000000..e6ff5f46 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TerrainColliderEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e47c360e7747b4840891bf1f1c1dbad4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TextMeshEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TextMeshEditor.cs new file mode 100644 index 00000000..3f955169 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TextMeshEditor.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(TextMesh), true)] + public class TextMeshEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(TextMesh); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("text"), new TextFieldAttribute(TextFieldType.Area), + new DescriptorAttribute("Text", "The text that is displayed.", "http://docs.unity3d.com/ScriptReference/TextMesh-text.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("font"), + new DescriptorAttribute("Font", "The Font used.", "http://docs.unity3d.com/ScriptReference/TextMesh-font.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("color"), + new DescriptorAttribute("Color", "The color used to render the text.", "http://docs.unity3d.com/ScriptReference/TextMesh-color.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("fontSize"), + new DescriptorAttribute("Font Size", "The font size to use (for dynamic fonts).", "http://docs.unity3d.com/ScriptReference/TextMesh-fontSize.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("characterSize"), + new DescriptorAttribute("Character Size", "The size of each character (This scales the whole text).", "http://docs.unity3d.com/ScriptReference/TextMesh-characterSize.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("tabSize"), + new DescriptorAttribute("Tab Size", "How much space will be inserted for a tab '\t' character. This is a multiplum of the 'spacebar' character offset.", "http://docs.unity3d.com/ScriptReference/TextMesh-tabSize.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("lineSpacing"), + new DescriptorAttribute("Line Spacing", "How much space will be in-between lines of text.", "http://docs.unity3d.com/ScriptReference/TextMesh-lineSpacing.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("offsetZ"), + new DescriptorAttribute("Z Offset", "How far should the text be offset from the transform.position.z when drawing.", "http://docs.unity3d.com/ScriptReference/TextMesh-offsetZ.html"))); + + + fields.Add(new InspectorField(type, Instances, type.GetProperty("fontStyle"), + new DescriptorAttribute("Font Style", "The font style to use (for dynamic fonts).", "http://docs.unity3d.com/ScriptReference/TextMesh-fontStyle.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("anchor"), + new DescriptorAttribute("Anchor", "Which point of the text shares the position of the Transform.", "http://docs.unity3d.com/ScriptReference/TextMesh-anchor.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("alignment"), + new DescriptorAttribute("Alignment", "How lines of text are aligned (Left, Right, Center).", "http://docs.unity3d.com/ScriptReference/TextMesh-alignment.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("richText"), + new DescriptorAttribute("Rich Text", "Enable HTML-style tags for Text Formatting Markup.", "http://docs.unity3d.com/ScriptReference/TextMesh-richText.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TextMeshEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TextMeshEditor.cs.meta new file mode 100644 index 00000000..aee5baa7 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TextMeshEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1943876aa3c70a848aeadef8f6a6b46b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TransformEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TransformEditor.cs new file mode 100644 index 00000000..3cea991f --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TransformEditor.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(Transform), true)] + public class TransformEditor : InspectorEditor + { + protected override void RefreshFields() + { + Type type = typeof(Transform); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("localPosition"), + new DescriptorAttribute("Position", "Position of the transform relative to the parent transform.", "http://docs.unity3d.com/ScriptReference/Transform-localPosition.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("localEulerAngles"), + new DescriptorAttribute("Rotation", "The rotation of the transform relative to the parent transform's rotation.", "http://docs.unity3d.com/ScriptReference/Transform-localRotation.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("localScale"), + new DescriptorAttribute("Scale", "The scale of the transform relative to the parent.", "http://docs.unity3d.com/ScriptReference/Transform-localScale.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("position"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("World Position", "The position of the transform in world space.", "http://docs.unity3d.com/ScriptReference/Transform-position.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("rotation"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("World Rotation", "The rotation of the transform in world space stored as a Quaternion.", "http://docs.unity3d.com/ScriptReference/Transform-rotation.html"))); + } + } +} diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TransformEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TransformEditor.cs.meta new file mode 100644 index 00000000..51386f31 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TransformEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4a8fde3da56bf6439cd4b5a39090868 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/WheelColliderEditor.cs b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/WheelColliderEditor.cs new file mode 100644 index 00000000..dd84d871 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/WheelColliderEditor.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; + +using UnityEditor; +using UnityEngine; + +namespace AdvancedInspector +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(WheelCollider), true)] + public class WheelColliderEditor : ColliderEditor + { + protected override void RefreshFields() + { + Type type = typeof(WheelCollider); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("mass"), + new DescriptorAttribute("Mass", "The mass of the wheel. Must be larger than zero.", "http://docs.unity3d.com/ScriptReference/WheelCollider-mass.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("radius"), + new DescriptorAttribute("Radius", "The radius of the wheel, measured in local space.", "http://docs.unity3d.com/ScriptReference/WheelCollider-radius.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("suspensionDistance"), + new DescriptorAttribute("Suspension Distance", "Maximum extension distance of wheel suspension, measured in local space.", "http://docs.unity3d.com/ScriptReference/WheelCollider-suspensionDistance.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("center"), + new DescriptorAttribute("Center", "The center of the wheel, measured in the object's local space.", "http://docs.unity3d.com/ScriptReference/WheelCollider-center.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("suspensionSpring"), new BypassAttribute(), + new DescriptorAttribute("Suspension Spring", "The parameters of wheel's suspension. The suspension attempts to reach a target position.", "http://docs.unity3d.com/ScriptReference/WheelCollider-suspensionSpring.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("forwardFriction"), + new DescriptorAttribute("Forward Friction", "Properties of tire friction in the direction the wheel is pointing in.", "http://docs.unity3d.com/ScriptReference/WheelCollider-forwardFriction.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("sidewaysFriction"), + new DescriptorAttribute("Sideways Friction", "Properties of tire friction in the sideways direction.", "http://docs.unity3d.com/ScriptReference/WheelCollider-sidewaysFriction.html"))); + + fields.Add(new InspectorField(type, Instances, type.GetProperty("brakeTorque"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Brake Torque", "Brake torque. Must be positive.", "http://docs.unity3d.com/ScriptReference/WheelCollider-brakeTorque.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("motorTorque"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Motor Torque", "Motor torque on the wheel axle. Positive or negative depending on direction.", "http://docs.unity3d.com/ScriptReference/WheelCollider-motorTorque.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("steerAngle"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Steer Angle", "Steering angle in degrees, always around the local y-axis.", "http://docs.unity3d.com/ScriptReference/WheelCollider-steerAngle.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("isGrounded"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("Is Grounded", "Indicates whether the wheel currently collides with something (Read Only).", "http://docs.unity3d.com/ScriptReference/WheelCollider-isGrounded.html"))); + fields.Add(new InspectorField(type, Instances, type.GetProperty("rpm"), new InspectAttribute(InspectorLevel.Advanced), + new DescriptorAttribute("RPM", "Current wheel axle rotation speed, in rotations per minute (Read Only).", "http://docs.unity3d.com/ScriptReference/WheelCollider-rpm.html"))); + } + } +}
\ No newline at end of file diff --git a/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/WheelColliderEditor.cs.meta b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/WheelColliderEditor.cs.meta new file mode 100644 index 00000000..1d401583 --- /dev/null +++ b/Assets/Plugins/Editor/AdvancedInspector/UnityTypes/WheelColliderEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b26718886a14c964687ac19bab859614 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: |