update
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bdf3813e1132bd4bbb17e142b6b37f5
|
||||
folderAsset: yes
|
||||
timeCreated: 1544055025
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,80 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(vBarDisplayAttribute), true)]
|
||||
public class vBarDisplayAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
Gradient g = new Gradient();
|
||||
GradientColorKey[] gck = new GradientColorKey[] { new GradientColorKey(Color.red, 0), new GradientColorKey(Color.yellow, 0.75f), new GradientColorKey(Color.green, 1) };
|
||||
GradientAlphaKey[] gak = new GradientAlphaKey[] { new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1) };
|
||||
Rect rectA;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var color = GUI.color;
|
||||
var atrbt = attribute as vBarDisplayAttribute;
|
||||
position.height = base.GetPropertyHeight(property, label);
|
||||
if (atrbt != null)
|
||||
{
|
||||
if (atrbt.showJuntInPlayMode && !Application.isPlaying)
|
||||
{
|
||||
EditorGUI.PropertyField(position, property, label);
|
||||
return;
|
||||
}
|
||||
|
||||
var maxValue = property.serializedObject.FindProperty(property.propertyPath.Replace(property.name, atrbt.maxValueProperty));
|
||||
if (maxValue != null)
|
||||
{
|
||||
GUI.BeginGroup(position, "", EditorStyles.toolbar);
|
||||
|
||||
float valueA = 0;
|
||||
float valueB = 0;
|
||||
switch (property.propertyType)
|
||||
{
|
||||
case SerializedPropertyType.Float:
|
||||
valueA = property.floatValue;
|
||||
break;
|
||||
case SerializedPropertyType.Integer:
|
||||
valueA = property.intValue;
|
||||
break;
|
||||
}
|
||||
switch (maxValue.propertyType)
|
||||
{
|
||||
case SerializedPropertyType.Float:
|
||||
valueB = maxValue.floatValue;
|
||||
break;
|
||||
case SerializedPropertyType.Integer:
|
||||
valueB = maxValue.intValue;
|
||||
break;
|
||||
}
|
||||
float currentValue = valueA / valueB;
|
||||
|
||||
g.SetKeys(gck, gak);
|
||||
GUI.color = g.Evaluate(currentValue);
|
||||
rectA = position;
|
||||
rectA.y = 0;
|
||||
rectA.x = 0;
|
||||
rectA.width = position.width * currentValue;
|
||||
|
||||
GUI.color = g.Evaluate(currentValue);
|
||||
GUI.Box(rectA, "");
|
||||
rectA.width = position.width;
|
||||
rectA.x = (position.width / 3);
|
||||
GUI.Label(rectA, property.displayName + ":" + valueA.ToString("0") + "/" + valueB.ToString("0"));
|
||||
GUI.EndGroup();
|
||||
position.y += base.GetPropertyHeight(property, label) + 5;
|
||||
}
|
||||
}
|
||||
GUI.color = color;
|
||||
|
||||
EditorGUI.PropertyField(position, property, label);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var atrbt = attribute as vBarDisplayAttribute;
|
||||
if (atrbt.showJuntInPlayMode && !Application.isPlaying)
|
||||
return base.GetPropertyHeight(property, label);
|
||||
else return (base.GetPropertyHeight(property, label) * 2f) + 5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 252cb1b4e9bfd5044b0dfd9a6c30728e
|
||||
timeCreated: 1519157384
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
namespace Invector
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(vButtonAttribute))]
|
||||
public class SingletonEditor : DecoratorDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
vButtonAttribute target = (vButtonAttribute)attribute;
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
GUI.enabled = target.enabledJustInPlayMode && Application.isPlaying || !target.enabledJustInPlayMode;
|
||||
Rect rect = position;
|
||||
rect.height = 20;
|
||||
if (GUI.Button(rect, new GUIContent(target.label, GUI.enabled ? "Call function " + target.function : "Enabled Just in Play Mode")))
|
||||
{
|
||||
ExecuteFunction(target);
|
||||
}
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override float GetHeight()
|
||||
{
|
||||
return 30f;
|
||||
}
|
||||
|
||||
void ExecuteFunction(vButtonAttribute target)
|
||||
{
|
||||
if (target.type == null) return;
|
||||
UnityEngine.Object theObject = Selection.activeGameObject.GetComponent(target.type) as UnityEngine.Object;
|
||||
|
||||
MethodInfo tMethod = theObject.GetType().GetMethods().FirstOrDefault(method => method.Name == target.function
|
||||
&& method.GetParameters().Count() == 0);
|
||||
|
||||
if (tMethod != null)
|
||||
{
|
||||
tMethod.Invoke(theObject,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08c6c4ad686732946958f3b63923829e
|
||||
timeCreated: 1469207365
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(vCheckPropertyAttribute),true)]
|
||||
public class vCheckPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
label = EditorGUI.BeginProperty(position, label, property);
|
||||
vCheckPropertyAttribute _attribute = attribute as vCheckPropertyAttribute;
|
||||
|
||||
if (_attribute != null && property.serializedObject.targetObject)
|
||||
{
|
||||
var propertyName = property.propertyPath.Replace(property.name, "");
|
||||
var checkValues = _attribute.checkValues;
|
||||
|
||||
var valid = Validate(property, _attribute);
|
||||
if (valid || !_attribute.hideInInspector)
|
||||
{
|
||||
GUI.enabled = valid;
|
||||
GUI.color = valid ? Color.white : Color.grey * 0.5f;
|
||||
|
||||
EditorGUI.PropertyField(position, property, label, true);
|
||||
GUI.enabled = true;
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
EditorGUI.PropertyField(position, property, true);
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
private bool Validate(SerializedProperty property, vCheckPropertyAttribute _attribute)
|
||||
{
|
||||
var propertyName = property.propertyPath.Replace(property.name, "");
|
||||
var checkValues = _attribute.checkValues;
|
||||
var valid = true;
|
||||
for (int i = 0; i < checkValues.Count; i++)
|
||||
{
|
||||
var prop = property.serializedObject.FindProperty(propertyName + checkValues[i].property);
|
||||
|
||||
switch (prop.propertyType)
|
||||
{
|
||||
case SerializedPropertyType.Boolean:
|
||||
valid = prop.boolValue.Equals(checkValues[i].value);
|
||||
break;
|
||||
case SerializedPropertyType.Enum:
|
||||
int index = Array.IndexOf(Enum.GetValues(checkValues[i].value.GetType()), checkValues[i].value);
|
||||
valid = prop.enumValueIndex.Equals(index);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!valid) break;
|
||||
}
|
||||
if (_attribute.invertResult) valid = !valid;
|
||||
return valid;
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
vCheckPropertyAttribute _attribute = attribute as vCheckPropertyAttribute;
|
||||
|
||||
var valid = Validate(property, _attribute) || !_attribute.hideInInspector;
|
||||
return valid?base.GetPropertyHeight(property, label):0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 795f336bc230ef247b0206beca796d22
|
||||
timeCreated: 1498054874
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof (vHelpBoxAttribute))]
|
||||
public class vHelpBoxDecorator : DecoratorDrawer
|
||||
{
|
||||
public Vector2 size;
|
||||
GUIStyle style = new GUIStyle(EditorStyles.helpBox);
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
if(style ==null) style = new GUIStyle(EditorStyles.helpBox);
|
||||
|
||||
var helpbox = attribute as vHelpBoxAttribute;
|
||||
|
||||
GUIContent content = new GUIContent(helpbox.text);
|
||||
|
||||
switch (helpbox.messageType)
|
||||
{
|
||||
case vHelpBoxAttribute.MessageType.Info:
|
||||
content = EditorGUIUtility.IconContent("console.infoicon", helpbox.text);
|
||||
break;
|
||||
case vHelpBoxAttribute.MessageType.Warning:
|
||||
content = EditorGUIUtility.IconContent("console.warnicon", helpbox.text);
|
||||
break;
|
||||
}
|
||||
content.text = helpbox.text;
|
||||
style.richText = true;
|
||||
GUI.Box(position, content, style);
|
||||
}
|
||||
|
||||
public override float GetHeight()
|
||||
{
|
||||
var helpBoxAttribute = attribute as vHelpBoxAttribute;
|
||||
if (helpBoxAttribute == null) return base.GetHeight();
|
||||
if (style == null) style = new GUIStyle(EditorStyles.helpBox);
|
||||
style.richText = true;
|
||||
if (style == null) return base.GetHeight();
|
||||
return Mathf.Max(EditorGUIUtility.singleLineHeight, style.CalcHeight(new GUIContent(helpBoxAttribute.text), EditorGUIUtility.currentViewWidth) + 10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cca213a8eff642b42b00c303fcdfb5e0
|
||||
timeCreated: 1527529455
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(vHideInInspectorAttribute),true)]
|
||||
public class vHideInInspectorDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
label = EditorGUI.BeginProperty(position, label, property);
|
||||
vHideInInspectorAttribute _attribute = attribute as vHideInInspectorAttribute;
|
||||
|
||||
if (_attribute != null && property.serializedObject.targetObject)
|
||||
{
|
||||
var propertyName = property.propertyPath.Replace(property.name, "");
|
||||
var booleamProperties = _attribute.refbooleanProperty.Split(';');
|
||||
for (int i = 0; i < booleamProperties.Length; i++)
|
||||
{
|
||||
var booleanProperty = property.serializedObject.FindProperty(propertyName + booleamProperties[i]);
|
||||
if (booleanProperty != null)
|
||||
{
|
||||
_attribute.hideProperty = (bool)_attribute.invertValue ? booleanProperty.boolValue : !booleanProperty.boolValue;
|
||||
if (_attribute.hideProperty)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
EditorGUI.PropertyField(position, property,label, true);
|
||||
}
|
||||
}
|
||||
if (!_attribute.hideProperty)
|
||||
{
|
||||
EditorGUI.PropertyField(position, property, label, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
EditorGUI.PropertyField(position, property, label, true);
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
vHideInInspectorAttribute _attribute = attribute as vHideInInspectorAttribute;
|
||||
if (_attribute != null)
|
||||
{
|
||||
var propertyName = property.propertyPath.Replace(property.name, "");
|
||||
var booleamProperties = _attribute.refbooleanProperty.Split(';');
|
||||
var valid = true;
|
||||
for (int i = 0; i < booleamProperties.Length; i++)
|
||||
{
|
||||
var booleamProperty = property.serializedObject.FindProperty(propertyName + booleamProperties[i]);
|
||||
if (booleamProperty != null)
|
||||
{
|
||||
valid = _attribute.invertValue ? !booleamProperty.boolValue : booleamProperty.boolValue;
|
||||
if (!valid) break;
|
||||
}
|
||||
}
|
||||
if (valid) return base.GetPropertyHeight(property, label);
|
||||
else return 0;
|
||||
}
|
||||
return base.GetPropertyHeight(property, label);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 557f303a83b630b4eb322ab5446593b5
|
||||
timeCreated: 1498054874
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Reflection;
|
||||
|
||||
[CustomPropertyDrawer(typeof(vMinMaxAttribute))]
|
||||
public class vMinMaxAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (property.propertyType != SerializedPropertyType.Vector2)
|
||||
{
|
||||
EditorGUI.PropertyField(position, property, true);return;
|
||||
}
|
||||
|
||||
Vector2 value = property.vector2Value;
|
||||
var minmax = attribute as vMinMaxAttribute;
|
||||
position.height = EditorGUIUtility.singleLineHeight;
|
||||
needLine = contextWidth < 400;
|
||||
label = EditorGUI.BeginProperty(position, label, property);
|
||||
if (needLine)
|
||||
{
|
||||
EditorGUI.LabelField(position, label);
|
||||
position.y += EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
}
|
||||
|
||||
var left = new Rect(position.x, position.y, 35, EditorGUIUtility.singleLineHeight);
|
||||
var middle = new Rect(position.x + 35, position.y, position.width - 70, EditorGUIUtility.singleLineHeight);
|
||||
var right = new Rect(position.x + position.width - 35, position.y, 35, EditorGUIUtility.singleLineHeight);
|
||||
value.x = Mathf.Clamp(EditorGUI.FloatField(left, value.x), minmax.minLimit, minmax.maxLimit);
|
||||
value.y = Mathf.Clamp(EditorGUI.FloatField(right, value.y), value.x, minmax.maxLimit);
|
||||
|
||||
|
||||
EditorGUI.MinMaxSlider(middle, GUIContent.none, ref value.x, ref value.y, minmax.minLimit, minmax.maxLimit);
|
||||
|
||||
property.vector2Value = value;
|
||||
EditorGUI.EndProperty();
|
||||
// base.OnGUI(position, property, label);
|
||||
}
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
needLine = contextWidth < 400;
|
||||
if (property.propertyType == SerializedPropertyType.Vector2)
|
||||
{
|
||||
|
||||
return EditorGUIUtility.singleLineHeight * (needLine ? 2:1f);
|
||||
}
|
||||
else return base.GetPropertyHeight(property, label) ;
|
||||
|
||||
}
|
||||
bool needLine;
|
||||
float contextWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorGUIUtility.currentViewWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d55fa4bb70d62f04baf64b394f5110c3
|
||||
timeCreated: 1555010343
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
namespace Invector
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(vReadOnlyAttribute))]
|
||||
public class vReadOnlyAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
|
||||
var att = attribute as vReadOnlyAttribute;
|
||||
if (att.justInPlayMode && !Application.isPlaying) return;
|
||||
string value = "Null";
|
||||
|
||||
switch (property.propertyType)
|
||||
{
|
||||
case SerializedPropertyType.Integer:
|
||||
value = property.intValue.ToString();
|
||||
break;
|
||||
case SerializedPropertyType.Boolean:
|
||||
value = property.boolValue.ToString();
|
||||
break;
|
||||
case SerializedPropertyType.Float:
|
||||
value = property.floatValue.ToString("0.0");
|
||||
break;
|
||||
case SerializedPropertyType.String:
|
||||
value = property.stringValue;
|
||||
break;
|
||||
|
||||
case SerializedPropertyType.Quaternion:
|
||||
value = property.quaternionValue.eulerAngles.ToString();
|
||||
break;
|
||||
case SerializedPropertyType.Vector2:
|
||||
value = property.vector2Value.ToString();
|
||||
break;
|
||||
case SerializedPropertyType.Vector3:
|
||||
value = property.vector3Value.ToString();
|
||||
break;
|
||||
case SerializedPropertyType.Enum:
|
||||
value = property.enumDisplayNames[property.enumValueIndex];
|
||||
break;
|
||||
case SerializedPropertyType.ObjectReference:
|
||||
value = "Null";
|
||||
break;
|
||||
default:
|
||||
value = "(not supported)";
|
||||
break;
|
||||
}
|
||||
|
||||
var fontStyle = GUI.skin.label.fontStyle;
|
||||
GUI.skin.label.fontStyle = FontStyle.BoldAndItalic;
|
||||
GUIStyle style = new GUIStyle(EditorStyles.wordWrappedLabel);
|
||||
style.fontStyle = FontStyle.BoldAndItalic;
|
||||
|
||||
style.normal.textColor = Color.black;
|
||||
style.alignment = TextAnchor.MiddleLeft;
|
||||
var rect = position;
|
||||
rect.width = position.width * 0.6f;
|
||||
EditorGUI.LabelField(rect, "", label.text, style);
|
||||
style.normal.textColor = property.propertyType == SerializedPropertyType.Boolean? property.boolValue?Color.green: Color.red:
|
||||
(property.propertyType == SerializedPropertyType.ObjectReference ? property.objectReferenceValue ? Color.green : Color.red : Color.black);
|
||||
style.alignment = TextAnchor.MiddleLeft;
|
||||
position.x += rect.width + 0.05f;
|
||||
position.width = position.width * 0.35f;
|
||||
if (property.propertyType == SerializedPropertyType.ObjectReference && property.objectReferenceValue) EditorGUI.ObjectField(position, property.objectReferenceValue,typeof(Object),true);
|
||||
else EditorGUI.LabelField(position, "", value, style);
|
||||
GUI.skin.label.fontStyle = fontStyle;
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var att = attribute as vReadOnlyAttribute;
|
||||
if (att.justInPlayMode && !Application.isPlaying) return 0;
|
||||
return base.GetPropertyHeight(property, label);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e348f117cf4edaf479decaeed6efdbef
|
||||
timeCreated: 1498693563
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
[CustomPropertyDrawer(typeof(vSeparator))]
|
||||
public class vSeparatorDrawer : DecoratorDrawer
|
||||
{
|
||||
vSeparator _separator;
|
||||
GUIStyle _style;
|
||||
GUIContent _content;
|
||||
public vSeparator separator
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_separator == null)
|
||||
{
|
||||
_separator = (vSeparator)attribute;
|
||||
}
|
||||
|
||||
return _separator;
|
||||
}
|
||||
}
|
||||
|
||||
public GUIStyle style
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_style == null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(separator.style))
|
||||
{
|
||||
_style = new GUIStyle(EditorStyles.helpBox);
|
||||
_style.fontStyle = FontStyle.Bold;
|
||||
_style.alignment = TextAnchor.UpperCenter;
|
||||
_style.fontSize = 12;
|
||||
_style.normal.textColor = new Color(1f, 0.5490196f, 0f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_style = new GUIStyle(separator.style);
|
||||
}
|
||||
}
|
||||
_style.richText = true;
|
||||
return _style;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public GUIContent content
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_content == null)
|
||||
{
|
||||
_content = new GUIContent(separator.label, separator.tooltip);
|
||||
}
|
||||
return _content;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
position.height = position.height - EditorGUIUtility.singleLineHeight;
|
||||
position.y += EditorGUIUtility.singleLineHeight * 0.5f;
|
||||
base.OnGUI(position);
|
||||
//style.fontSize = separator.fontSize;
|
||||
GUI.Box(position, new GUIContent(separator.label, separator.tooltip), style);
|
||||
}
|
||||
|
||||
public override float GetHeight()
|
||||
{
|
||||
//style.fontSize = separator.fontSize;
|
||||
return style.CalcHeight(content, EditorGUIUtility.currentViewWidth) + EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fe287b7356c9cd4ab0a38a8d891f548
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(vTagMask), true)]
|
||||
public class vTagMaskDrawer : PropertyDrawer
|
||||
{
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var prop = property.FindPropertyRelative("tags");
|
||||
EditorGUI.BeginProperty(position, label, prop);
|
||||
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||
var tags = GetTagList(prop);
|
||||
if (EditorGUI.DropdownButton(position, new GUIContent(prop.arraySize == 0 ? "Nothing" : prop.arraySize <= 4 ? Get4FirstNames(prop) : "Mixed ..."), FocusType.Passive, EditorStyles.popup))
|
||||
{
|
||||
for (int i = 0; i < prop.arraySize; i++)
|
||||
{
|
||||
var p = prop.GetArrayElementAtIndex(i);
|
||||
if (p.propertyType == SerializedPropertyType.String)
|
||||
tags.Add(p.stringValue);
|
||||
}
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(new GUIContent("Nothing"), tags.Count == 0, () => { prop.ClearArray(); prop.serializedObject.ApplyModifiedProperties(); });
|
||||
menu.AddItem(new GUIContent("Everything"), tags.Count == UnityEditorInternal.InternalEditorUtility.tags.Length, () => {
|
||||
prop.ClearArray();
|
||||
foreach (var t in UnityEditorInternal.InternalEditorUtility.tags)
|
||||
{
|
||||
prop.arraySize++;
|
||||
prop.GetArrayElementAtIndex(prop.arraySize - 1).stringValue = t;
|
||||
}
|
||||
prop.serializedObject.ApplyModifiedProperties();
|
||||
});
|
||||
foreach (var t in UnityEditorInternal.InternalEditorUtility.tags)
|
||||
menu.AddItem(new GUIContent(t), tags.Contains(t), () => { CheckValue(prop, tags, t); });
|
||||
menu.DropDown(position);
|
||||
|
||||
}
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
string Get4FirstNames(SerializedProperty prop)
|
||||
{
|
||||
string names = "";
|
||||
for (int i = 0; i < prop.arraySize; i++)
|
||||
{
|
||||
var p = prop.GetArrayElementAtIndex(i);
|
||||
if (p != null && p.propertyType == SerializedPropertyType.String)
|
||||
{
|
||||
names += p.stringValue;
|
||||
if (i < prop.arraySize - 1) names += ", ";
|
||||
}
|
||||
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public List<string> GetTagList(SerializedProperty prop)
|
||||
{
|
||||
List<string> tags = new List<string>();
|
||||
for (int i = 0; i < prop.arraySize; i++)
|
||||
{
|
||||
var p = prop.GetArrayElementAtIndex(i);
|
||||
if (p != null && p.propertyType == SerializedPropertyType.String)
|
||||
{
|
||||
tags.Add(p.stringValue);
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void CheckValue(SerializedProperty prop, List<string> propToList, string valueSelected)
|
||||
{
|
||||
if (propToList.Contains(valueSelected))
|
||||
{
|
||||
prop.DeleteArrayElementAtIndex(propToList.IndexOf(valueSelected));
|
||||
prop.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
prop.arraySize++;
|
||||
prop.GetArrayElementAtIndex(prop.arraySize - 1).stringValue = valueSelected;
|
||||
prop.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e34712f7edd1c1844b053d9b4ed9f4da
|
||||
timeCreated: 1518738141
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
[CustomPropertyDrawer(typeof(vToggleOptionAttribute),true)]
|
||||
public class vToggleOptionAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if(property.propertyType == SerializedPropertyType.Boolean)
|
||||
{
|
||||
|
||||
var toogle = attribute as vToggleOptionAttribute;
|
||||
if (toogle.label != "") label.text = toogle.label;
|
||||
var options = new GUIContent[] { new GUIContent( toogle.falseValue), new GUIContent(toogle.trueValue) };
|
||||
property.boolValue = Convert.ToBoolean(EditorGUI.Popup(position,label, Convert.ToInt32(property.boolValue), options));
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.PropertyField(position, property, label,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ed1909ee22be2c4ca004bf81f3e2276
|
||||
timeCreated: 1530303471
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
|
||||
public class vBarDisplayAttribute : PropertyAttribute
|
||||
{
|
||||
public readonly string maxValueProperty;
|
||||
public readonly bool showJuntInPlayMode;
|
||||
public vBarDisplayAttribute(string maxValueProperty, bool showJuntInPlayMode = false)
|
||||
{
|
||||
this.maxValueProperty = maxValueProperty;
|
||||
this.showJuntInPlayMode = showJuntInPlayMode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 096a2b9fad602c041a4ce6cd5ee15d01
|
||||
timeCreated: 1529518712
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
namespace Invector
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = true)]
|
||||
public class vButtonAttribute : PropertyAttribute
|
||||
{
|
||||
public readonly string label;
|
||||
public readonly string function;
|
||||
public readonly int id;
|
||||
public readonly Type type;
|
||||
public readonly bool enabledJustInPlayMode;
|
||||
|
||||
/// <summary>
|
||||
/// Create a button in Inspector
|
||||
/// </summary>
|
||||
/// <param name="label">button label</param>
|
||||
/// <param name="function">function to call on press</param>
|
||||
/// <param name="type">parent class type button</param>
|
||||
/// <param name="enabledJustInPlayMode">button is enabled just in play mode</param>
|
||||
public vButtonAttribute(string label, string function, Type type, bool enabledJustInPlayMode = true)
|
||||
{
|
||||
this.label = label;
|
||||
this.function = function;
|
||||
this.type = type;
|
||||
this.enabledJustInPlayMode = enabledJustInPlayMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6ae96fdc6b575249a94367b25cefb95
|
||||
timeCreated: 1529519547
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
/// <summary>
|
||||
/// Check Property is used to validate field using other filds.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = true)]
|
||||
public class vCheckPropertyAttribute : PropertyAttribute
|
||||
{
|
||||
[Serializable]
|
||||
public struct CheckValue
|
||||
{
|
||||
public string property;
|
||||
public object value;
|
||||
|
||||
public bool isValid => value != null;
|
||||
public CheckValue(string property, object value)
|
||||
{
|
||||
this.property = property;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<CheckValue> checkValues = new List<CheckValue>();
|
||||
|
||||
public bool hideInInspector;
|
||||
public bool invertResult;
|
||||
/// <summary>
|
||||
/// Check Property is used to validate field using other filds.
|
||||
/// </summary>
|
||||
/// <param name="propertyNames"> Properties names separated by "," (comma) Exemple "PropertyA,PropertyB". Only Enum and Boolean is accepted.</param>
|
||||
/// <param name="values">The values to compare, you need to set all values to compare with all properties</param>
|
||||
public vCheckPropertyAttribute(string propertyNames, params object[] values)
|
||||
{
|
||||
|
||||
checkValues.Clear();
|
||||
var _props = propertyNames.Split(',');
|
||||
|
||||
for (int i = 0; i < _props.Length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
checkValues.Add(new CheckValue(_props[i], values[i]));
|
||||
}
|
||||
catch
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad78f56404d97374c84c434f24b141c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
|
||||
public sealed class vClassHeaderAttribute : Attribute
|
||||
{
|
||||
public string header;
|
||||
public bool openClose;
|
||||
public string iconName;
|
||||
public bool useHelpBox;
|
||||
public string helpBoxText;
|
||||
|
||||
public vClassHeaderAttribute(string header, bool openClose = true, string iconName = "icon_v2", bool useHelpBox = false, string helpBoxText = "")
|
||||
{
|
||||
this.header = header.ToUpper();
|
||||
this.openClose = openClose;
|
||||
this.iconName = iconName;
|
||||
this.useHelpBox = useHelpBox;
|
||||
this.helpBoxText = helpBoxText;
|
||||
}
|
||||
|
||||
public vClassHeaderAttribute(string header, string helpBoxText)
|
||||
{
|
||||
this.header = header.ToUpper();
|
||||
this.openClose = true;
|
||||
this.iconName = "icon_v2";
|
||||
this.useHelpBox = true;
|
||||
this.helpBoxText = helpBoxText;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f405ef569ee722147b66f6e87bc448ef
|
||||
timeCreated: 1529518590
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
namespace Invector
|
||||
{
|
||||
public class vEditorToolbarAttribute : PropertyAttribute
|
||||
{
|
||||
public readonly string title;
|
||||
public readonly string icon;
|
||||
public readonly bool useIcon;
|
||||
public readonly bool overrideChildOrder;
|
||||
public readonly bool overrideIcon;
|
||||
public vEditorToolbarAttribute(string title, bool useIcon = false, string iconName = "", bool overrideIcon = false, bool overrideChildOrder = false)
|
||||
{
|
||||
this.title = title;
|
||||
this.icon = iconName;
|
||||
this.useIcon = useIcon;
|
||||
this.overrideChildOrder = overrideChildOrder;
|
||||
this.overrideIcon = overrideIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9010aa46101362a488c76277e19623e0
|
||||
timeCreated: 1529518614
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field,AllowMultiple =true)]
|
||||
public class vHelpBoxAttribute : PropertyAttribute
|
||||
{
|
||||
public string text;
|
||||
public vHelpBoxAttribute(string text, MessageType messageType = MessageType.None) { this.text = text; this.messageType = messageType; }
|
||||
public int lineSpace;
|
||||
|
||||
public enum MessageType
|
||||
{
|
||||
None,
|
||||
Info,
|
||||
Warning
|
||||
}
|
||||
|
||||
public MessageType messageType;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6ac28d2168f93e43a0b2454325486c0
|
||||
timeCreated: 1529518913
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
namespace Invector
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = true)]
|
||||
public class vHideInInspectorAttribute : PropertyAttribute
|
||||
{
|
||||
public bool hideProperty { get; set; }
|
||||
public string refbooleanProperty;
|
||||
public bool invertValue;
|
||||
public vHideInInspectorAttribute(string refbooleanProperty, bool invertValue = false)
|
||||
{
|
||||
this.refbooleanProperty = refbooleanProperty;
|
||||
this.invertValue = invertValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a86e5138f69f693439455d5eff277713
|
||||
timeCreated: 1529518900
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class vMinMaxAttribute : PropertyAttribute
|
||||
{
|
||||
public float minLimit = 0;
|
||||
public float maxLimit = 1f;
|
||||
public vMinMaxAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
public vMinMaxAttribute(float min, float max)
|
||||
{
|
||||
minLimit = min;
|
||||
maxLimit = max;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57d05196792a06748ad8042cdf0fc573
|
||||
timeCreated: 1555009967
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
namespace Invector
|
||||
{
|
||||
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
|
||||
public class vReadOnlyAttribute : PropertyAttribute
|
||||
{
|
||||
public readonly bool justInPlayMode;
|
||||
|
||||
public vReadOnlyAttribute(bool justInPlayMode = true)
|
||||
{
|
||||
this.justInPlayMode = justInPlayMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44980ddaec236754c96bccd5b9af9d05
|
||||
timeCreated: 1529518700
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = true)]
|
||||
public class vSeparator : PropertyAttribute
|
||||
{
|
||||
public string label;
|
||||
public string tooltip;
|
||||
public string style;
|
||||
public int fontSize = 10;
|
||||
|
||||
public vSeparator()
|
||||
{
|
||||
fontSize = 15;
|
||||
}
|
||||
|
||||
public vSeparator(string label, string tooltip = "")
|
||||
{
|
||||
this.label = label;
|
||||
this.tooltip = tooltip;
|
||||
this.fontSize = 15;
|
||||
}
|
||||
|
||||
public vSeparator(string label, int fontSize, string tooltip = "")
|
||||
{
|
||||
this.label = label;
|
||||
this.tooltip = tooltip;
|
||||
this.fontSize = fontSize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8615c74e7fb0c84409242a7d9420676b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
|
||||
public class vToggleOptionAttribute : PropertyAttribute
|
||||
{
|
||||
public string label, falseValue, trueValue;
|
||||
public vToggleOptionAttribute(string label = "", string falseValue = "No", string trueValue = "Yes")
|
||||
{
|
||||
this.label = label;
|
||||
this.falseValue = falseValue;
|
||||
this.trueValue = trueValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f0d65062c21c764ca1972dd44c8a034
|
||||
timeCreated: 1530303202
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user