This commit is contained in:
2026-05-30 09:16:35 +07:00
parent 2f87ce19a7
commit 1c0ee6efb7
4001 changed files with 3363438 additions and 1738 deletions

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 367485ae42aabf34a8d3176250797d93
folderAsset: yes
timeCreated: 1544048826
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: c468d3c4271625747837f4a3db1aa488
folderAsset: yes
timeCreated: 1544056112
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,121 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Invector.vEventSystems
{
[CustomEditor(typeof(vAnimatorEvent))]
public class vAnimatorEventEditor : UnityEditor.Editor
{
public vAnimatorEvent animatorEvent;
public GUISkin skin;
public GUIStyle timeLineStyle;
private void OnEnable()
{
animatorEvent = target as vAnimatorEvent;
}
public override void OnInspectorGUI()
{
if (!skin) skin = Resources.Load("vSkin") as GUISkin;
if (timeLineStyle == null) timeLineStyle = new GUIStyle(EditorStyles.inspectorFullWidthMargins);
serializedObject.Update();
EditorGUILayout.BeginVertical(skin.box);
EditorGUILayout.HelpBox("<b>Make sure to use a lower value than the Exit Time of this State.</b>", MessageType.Warning);
var events = serializedObject.FindProperty("eventTriggers");
if (GUILayout.Button("Add Event", skin.button, GUILayout.ExpandWidth(true)))
{
events.arraySize++;
events.GetArrayElementAtIndex(events.arraySize - 1).FindPropertyRelative("eventName").stringValue = "New Event";
}
for (int i = 0; i < events.arraySize; i++)
{
if (!DraEvent(events, i)) break;
}
EditorGUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
}
public bool DraEvent(SerializedProperty list, int index)
{
EditorGUILayout.BeginVertical(skin.box, GUILayout.ExpandWidth(true));
{
var eventName = list.GetArrayElementAtIndex(index).FindPropertyRelative("eventName");
var eventTriggerType = list.GetArrayElementAtIndex(index).FindPropertyRelative("eventTriggerType");
var normalizedTime = list.GetArrayElementAtIndex(index).FindPropertyRelative("normalizedTime");
var width = 30;
EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
{
eventName.stringValue = EditorGUILayout.TextField(GUIContent.none, eventName.stringValue, GUILayout.ExpandWidth(true));
if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(width)))
{
list.DeleteArrayElementAtIndex(index);
return false;
}
}
EditorGUILayout.EndHorizontal();
eventTriggerType.enumValueIndex = (int)(vAnimatorEvent.vAnimatorEventTrigger.vAnimatorEventTriggerType)EditorGUILayout.EnumPopup("Type",(vAnimatorEvent.vAnimatorEventTrigger.vAnimatorEventTriggerType)eventTriggerType.enumValueIndex);
var valueSelected = (vAnimatorEvent.vAnimatorEventTrigger.vAnimatorEventTriggerType)eventTriggerType.enumValueIndex;
switch (valueSelected)
{
case vAnimatorEvent.vAnimatorEventTrigger.vAnimatorEventTriggerType.NormalizedTime:
Rect rect = GUILayoutUtility.GetLastRect();
GUILayout.Space(20);
var color = GUI.color;
rect.y += 20;
rect.width -= width;
GUI.Box(rect, "", skin.GetStyle("AnimatorEventBar"));
int number = 0;
for (int i = 0; i < 101; i++)
{
timeLineStyle.alignment = TextAnchor.UpperCenter;
var rectAdjust = new Rect(rect.position.x + ((rect.width - 5) * (0.01f * i)), rect.position.y, 2.5f, 15);
var par = i % 10f;
timeLineStyle.fontSize = par == 0 ? 15 : par == 5 ? (rect.width * 0.01f > 3f) ? 10 : 5 : (rect.width * 0.01f > 4f) ? 5 : 1;
rectAdjust.y += par == 0 ? -2 : par == 5 ? (rect.width * 0.01f > 3f) ? -1 : 0 : 0;
timeLineStyle.normal.textColor = Color.grey;
GUI.Box(rectAdjust, "|", timeLineStyle);
rectAdjust.y = rect.position.y + 5;
if (par == 0)
{
timeLineStyle.normal.textColor = Color.black;
timeLineStyle.alignment = TextAnchor.MiddleLeft;
timeLineStyle.fontSize = Mathf.Clamp((int)(rect.width * 0.02f), 6, 10);
rectAdjust.width = 25;
rectAdjust.height = 15;
rectAdjust.x += number < 10 ? -1 : -7;
GUI.Label(rectAdjust, (number * 0.1f).ToString(), timeLineStyle);
number++;
}
}
GUI.color = color;
rect.x -= 5;
rect.width += 10;
normalizedTime.floatValue = GUI.HorizontalSlider(rect, normalizedTime.floatValue, 0f, 1f, GUIStyle.none, skin.GetStyle("AnimatorEventThumb"));
rect.x = rect.x + rect.width - 3;
rect.width = width - 2;
normalizedTime.floatValue = EditorGUI.FloatField(rect, (float)System.Math.Round(normalizedTime.floatValue, 2));
break;
}
}
EditorGUILayout.EndVertical();
return true;
}
protected void DrawNormalizeEventStyle()
{
}
public override bool UseDefaultMargins()
{
return false;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c42db7cd67599b24c8dcc3c52e92fc83
timeCreated: 1542813635
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,85 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Invector.vEventSystems
{
[CustomEditor(typeof(vAnimatorTagAdvanced))]
public class vAnimatorTagAdvancedEditor : vAnimatorTagEditor
{
public override bool DrawTag(SerializedProperty list, int index)
{
GUILayout.BeginHorizontal(skin.box);
GUILayout.BeginVertical();
var tagToDraw = list.GetArrayElementAtIndex(index);
var tagName = tagToDraw.FindPropertyRelative("tagName");
var enumTagType = tagToDraw.FindPropertyRelative("tagType");
var normalizedTime = tagToDraw.FindPropertyRelative("normalizedTime");
DrawTagField(tagName);
EditorGUILayout.PropertyField(enumTagType, GUILayout.Height(15));
Vector2 minMax = normalizedTime.vector2Value;
var _enumTagType = (vAnimatorTagAdvanced.vAnimatorEventTriggerType)(enumTagType.enumValueIndex);
switch(_enumTagType)
{
case vAnimatorTagAdvanced.vAnimatorEventTriggerType.AllByNormalizedTime:
GUILayout.Label("Enter in " + minMax.x.ToString("0.00") + " - Exit in "+minMax.y.ToString("0.00"));
GUILayout.BeginHorizontal();
minMax.x = EditorGUILayout.FloatField(minMax.x,GUILayout.MaxWidth(40));
EditorGUILayout.MinMaxSlider(ref minMax.x, ref minMax.y, 0, 1f);
minMax.y = EditorGUILayout.FloatField(minMax.y, GUILayout.MaxWidth(40));
GUILayout.EndHorizontal();
if(GUI.changed)
{
minMax.x =(float) System.Math.Round(minMax.x, 2);
minMax.y = (float)System.Math.Round(minMax.y, 2);
normalizedTime.vector2Value = minMax;
}
break;
case vAnimatorTagAdvanced.vAnimatorEventTriggerType.EnterStateExitByNormalized:
GUILayout.Label("Exit in " + minMax.y.ToString("0.00"));
minMax.y = EditorGUILayout.Slider(minMax.y, 0, 1f);
if (GUI.changed)
{
minMax.x = 0;
minMax.y = (float)System.Math.Round(minMax.y, 2);
normalizedTime.vector2Value = minMax;
}
break;
case vAnimatorTagAdvanced.vAnimatorEventTriggerType.EnterByNormalizedExitState:
GUILayout.Label("Enter in " + minMax.x.ToString("0.00"));
minMax.x = EditorGUILayout.Slider(minMax.x, 0, 1f);
if (GUI.changed)
{
minMax.x = (float)System.Math.Round(minMax.x, 2);
minMax.y = 0;
normalizedTime.vector2Value = minMax;
}
break;
}
GUILayout.EndVertical();
if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)))
{
list.DeleteArrayElementAtIndex(index);
return false;
}
GUILayout.EndHorizontal();
return true;
}
protected override void AddTag(SerializedProperty list, string tag)
{
list.arraySize++;
var p = list.GetArrayElementAtIndex(list.arraySize - 1);
p.FindPropertyRelative("tagName").stringValue = tag;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 040e47635276c35468fdb6a920366ef1
timeCreated: 1542821872
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,116 @@
using UnityEditor;
using UnityEngine;
namespace Invector.vEventSystems
{
[CustomEditor(typeof(vAnimatorTag), true)]
public class vAnimatorTagEditor : UnityEditor.Editor
{
public GUISkin skin;
Rect buttonRect;
protected virtual string[] propertiesExcluded => new string[] { "tags", "stateInfos" };
public override void OnInspectorGUI()
{
if (!skin) skin = Resources.Load("vSkin") as GUISkin;
serializedObject.Update();
GUILayout.BeginVertical(skin.box);
DrawPropertiesExcluding(serializedObject, propertiesExcluded);
var tags = serializedObject.FindProperty("tags");
if (GUILayout.Button("Add New Tag", EditorStyles.miniButton, GUILayout.ExpandWidth(true)))
{
PopupWindow.Show(buttonRect, new TagListPopup((string value) => { Undo.RecordObject(serializedObject.targetObject, "Add Tag"); AddTag(tags, value); serializedObject.ApplyModifiedProperties(); }));
}
if (Event.current.type == EventType.Repaint) buttonRect = GUILayoutUtility.GetLastRect();
for (int i = 0; i < tags.arraySize; i++)
{
if (!DrawTag(tags, i)) break;
}
GUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
}
protected virtual void AddTag(SerializedProperty list, string tag)
{
list.arraySize++;
list.GetArrayElementAtIndex(list.arraySize - 1).stringValue = tag;
}
public virtual bool DrawTag(SerializedProperty list, int index)
{
GUILayout.BeginHorizontal(skin.box);
GUILayout.BeginVertical();
DrawTagField(list.GetArrayElementAtIndex(index));
GUILayout.Space(-10);
GUILayout.EndVertical();
if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)))
{
list.DeleteArrayElementAtIndex(index);
return false;
}
GUILayout.EndHorizontal();
return true;
}
public virtual void DrawTagField(SerializedProperty tag)
{
var info = EditorGUIUtility.IconContent("_Help");
info.tooltip = vAnimatorTagEditorHelper.GetTooltip(tag.stringValue);
bool isDefault = vAnimatorTagEditorHelper.IsDefaultTag(tag.stringValue);
GUILayout.BeginHorizontal();
GUILayout.Label(info);
Color color = GUI.contentColor;
GUI.contentColor = isDefault ? Color.green : color;
tag.stringValue = EditorGUILayout.TextField(tag.stringValue, isDefault ? vAnimatorTagEditorHelper.DefaultTagStyle : vAnimatorTagEditorHelper.CustomTagStyle);
GUI.contentColor = color;
GUILayout.EndHorizontal();
}
public class TagListPopup : PopupWindowContent
{
Vector2 scrollview;
System.Action<string> onSelect;
GUIStyle style;
public TagListPopup(System.Action<string> onSelect)
{
this.onSelect = onSelect;
style = new GUIStyle(GUI.skin.box);
style.fontStyle = FontStyle.Italic;
}
public override Vector2 GetWindowSize()
{
float height = GUI.skin.box.CalcHeight(new GUIContent("TAG"), 200) + EditorGUIUtility.standardVerticalSpacing * 2;
float minHeight = height * 10;
height *= vAnimatorTagEditorHelper.TAGS.Count + 1;
return new Vector2(200, Mathf.Min(height, minHeight) + EditorGUIUtility.standardVerticalSpacing * 4);
}
public override void OnGUI(Rect rect)
{
GUILayout.BeginArea(rect);
scrollview = GUILayout.BeginScrollView(scrollview);
if (GUILayout.Button(new GUIContent("Add Custom Tag...", "Create a New Custom Tag"), style, GUILayout.ExpandWidth(true)))
{
onSelect?.Invoke("");
editorWindow.Close();
}
foreach (string key in vAnimatorTagEditorHelper.TAGS.Keys)
{
string tooltip = vAnimatorTagEditorHelper.GetTooltip(key);
if (GUILayout.Button(new GUIContent(key, tooltip), "box", GUILayout.ExpandWidth(true)))
{
onSelect?.Invoke(key);
editorWindow.Close();
}
}
GUILayout.EndScrollView();
GUILayout.EndArea();
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ccd2dec28aae60c4cb7bcec0a0d4e5a9
timeCreated: 1542821872
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,82 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
namespace Invector
{
[InitializeOnLoad]
public static class vAnimatorTagEditorHelper
{
private static GUIStyle _customTagStyle;
private static GUIStyle _defaultTagStyle;
static vAnimatorTagEditorHelper()
{
TAGS = new Dictionary<string, TooltipAttribute>();
FieldInfo[] fields = typeof(vAnimatorTags).GetFields(BindingFlags.Public | BindingFlags.Static);
for (int i = 0; i < fields.Length; i++)
{
if(fields[i].FieldType.Equals(typeof(string)))
{
string fieldvalue = (string)fields[i].GetValue(null);
if(!TAGS.ContainsKey(fieldvalue))
{
TAGS.Add(fieldvalue, fields[i].GetCustomAttribute<TooltipAttribute>());
}
}
}
}
public static string GetTooltip(string tag)
{
if (TAGS!=null && TAGS.ContainsKey(tag))
{
TooltipAttribute tooltipAttribute = TAGS[tag];
string tooltip = tooltipAttribute!=null ? tooltipAttribute.tooltip : "";
return tooltip;
}
return "You can use custom tags with the method 'IsAnimatorTag(customTag)' to create special conditions in your code while this animation is being played";
}
public static Dictionary<string, TooltipAttribute> TAGS
{
get;
private set;
}
public static GUIStyle CustomTagStyle
{
get
{
if (_customTagStyle == null)
{
_customTagStyle = new GUIStyle(EditorStyles.textField);
_customTagStyle.fontStyle = FontStyle.Italic;
_customTagStyle.fontSize = EditorStyles.textField.fontSize - 1;
}
return _customTagStyle;
}
}
public static GUIStyle DefaultTagStyle
{
get
{
if(_defaultTagStyle==null)
{
_defaultTagStyle = new GUIStyle(EditorStyles.textField);
_defaultTagStyle.fontStyle = FontStyle.Bold;
}
return _defaultTagStyle;
}
}
public static bool IsDefaultTag(string tag)
{
return TAGS != null && TAGS.ContainsKey(tag);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 81c54afc56909af44b2fb77cd6059f43
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,166 @@
using System.Collections.Generic;
using UnityEngine;
namespace Invector.vEventSystems
{
public class vAnimatorEvent : StateMachineBehaviour
{
[System.Serializable]
public class vAnimatorEventTrigger
{
public enum vAnimatorEventTriggerType
{
NormalizedTime, EnterState, ExitState
}
public string eventName = "New Event";
public vAnimatorEventTriggerType eventTriggerType = vAnimatorEventTriggerType.NormalizedTime;
public float normalizedTime;
private int loopCount;
public event OnTriggerEvent onTriggerEvent;
public void UpdateEventTrigger(float normalizedTime)
{
var normalizedTimeClamped = Mathf.Clamp(normalizedTime, 0, loopCount + 1f);
if (normalizedTimeClamped >= loopCount + this.normalizedTime)
{
if (onTriggerEvent != null)
{
onTriggerEvent(eventName);
}
loopCount++;
}
}
public void TriggerEvent()
{
if (onTriggerEvent != null)
{
onTriggerEvent(eventName);
}
}
public void Init()
{
loopCount = 0;
}
}
public List<vAnimatorEventTrigger> eventTriggers;
public delegate void OnTriggerEvent(string eventName);
protected bool hasNormalizedEvents;
public bool HasEvent(string eventName)
{
return eventTriggers.Exists(e => e.eventName.Equals(eventName));
}
public void RegisterEvents(string eventName, OnTriggerEvent onTriggerEvent)
{
var _events = eventTriggers.FindAll(e => e.eventName.Equals(eventName));
for (int i = 0; i < _events.Count; i++)
{
_events[i].onTriggerEvent -= onTriggerEvent;
_events[i].onTriggerEvent += onTriggerEvent;
}
}
public void RemoveEvents(string eventName, OnTriggerEvent onTriggerEvent)
{
var _events = eventTriggers.FindAll(e => e.eventName.Equals(eventName));
for (int i = 0; i < _events.Count; i++)
{
_events[i].onTriggerEvent -= onTriggerEvent;
}
}
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
for (int i = 0; i < eventTriggers.Count; i++)
{
if (eventTriggers[i].eventTriggerType == vAnimatorEventTrigger.vAnimatorEventTriggerType.EnterState)
{
eventTriggers[i].TriggerEvent();
}
else if (eventTriggers[i].eventTriggerType == vAnimatorEventTrigger.vAnimatorEventTriggerType.NormalizedTime)
{
hasNormalizedEvents = true;
eventTriggers[i].Init();
eventTriggers[i].UpdateEventTrigger(stateInfo.normalizedTime);
}
}
}
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (!stateInfo.loop && stateInfo.normalizedTime > 1 || !hasNormalizedEvents)
{
return;
}
for (int i = 0; i < eventTriggers.Count; i++)
{
if (eventTriggers[i].eventTriggerType == vAnimatorEventTrigger.vAnimatorEventTriggerType.NormalizedTime)
{
eventTriggers[i].UpdateEventTrigger(stateInfo.normalizedTime);
}
}
}
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
for (int i = 0; i < eventTriggers.Count; i++)
{
if (eventTriggers[i].eventTriggerType == vAnimatorEventTrigger.vAnimatorEventTriggerType.ExitState)
{
eventTriggers[i].TriggerEvent();
}
}
}
}
}
namespace Invector
{
public static class vAnimatorEventExtencion
{
/// <summary>
/// Add event to the <seealso cref="vAnimatorEvent"/> in animator
/// </summary>
/// <param name="animator">target animator</param>
/// <param name="eventName">event name</param>
/// <param name="onTriggerEventAction">action to add to <seealso cref="vEventSystems.vAnimatorEvent"/></param>
public static void RegisterEvent(this Animator animator, string eventName, vEventSystems.vAnimatorEvent.OnTriggerEvent onTriggerEventAction)
{
if (animator)
{
var behaviours = animator.GetBehaviours<vEventSystems.vAnimatorEvent>();
for (int i = 0; i < behaviours.Length; i++)
{
if (behaviours[i].HasEvent(eventName))
{
behaviours[i].RegisterEvents(eventName, onTriggerEventAction);
}
}
}
}
/// <summary>
/// Remove event of the <seealso cref="vEventSystems.vAnimatorEvent"/> in animator
/// </summary>
/// <param name="animator">target animator</param>
/// <param name="eventName">event name</param>
/// <param name="onTriggerEventAction">action to remove of the <seealso cref="vAnimatorEvent"/></param>
public static void RemoveEvent(this Animator animator, string eventName, vEventSystems.vAnimatorEvent.OnTriggerEvent onTriggerEventAction)
{
if (animator)
{
var behaviours = animator.GetBehaviours<vEventSystems.vAnimatorEvent>();
for (int i = 0; i < behaviours.Length; i++)
{
if (behaviours[i].HasEvent(eventName))
{
behaviours[i].RemoveEvents(eventName, onTriggerEventAction);
}
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f223dbf5c9c4b5f46a7dbfa1a717fc27
timeCreated: 1542810410
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,135 @@
using System.Collections.Generic;
using UnityEngine;
namespace Invector.vEventSystems
{
[vClassHeader("Animator Event Receiver")]
public class vAnimatorEventReceiver : vMonoBehaviour
{
[Tooltip("Check this option if the Animator component is on the parent of this GameObject")]
public bool getAnimatorInParent;
[vHelpBox("Use <b>vAnimatorEvent</b> on a AnimatorState to trigger a Event below", vHelpBoxAttribute.MessageType.Info)]
public List<vAnimatorEvent> animatorEvents;
[System.Serializable]
public class vAnimatorEvent
{
[System.Serializable]
public class StateEvent : UnityEngine.Events.UnityEvent<string> { }
public string eventName;
public bool debug;
public StateEvent onTriggerEvent;
public virtual void OnTriggerEvent(string eventName)
{
if (debug)
{
Debug.Log("<color=green><b>Event " + eventName + " was called</b></color>");
}
onTriggerEvent.Invoke(eventName);
}
}
private bool hasValidBehaviours;
private bool hasAnimator;
private void Start()
{
RegisterEvents();
}
private void OnDisable()
{
RemoveEvents();
}
public void OnEnable()
{
if (hasAnimator && hasValidBehaviours)
{
RemoveEvents();
RegisterEvents();
}
}
private void OnDestroy()
{
RemoveEvents();
}
public virtual void RegisterEvents()
{
if (animatorEvents.Count > 0)
{
var animator = getAnimatorInParent ? GetComponentInParent<Animator>() : GetComponent<Animator>();
if (getAnimatorInParent && animator.gameObject == gameObject && transform.parent)
{
animator = transform.parent.GetComponentInParent<Animator>();
}
if (animator)
{
hasAnimator = true;
var behaviours = animator.GetBehaviours<Invector.vEventSystems.vAnimatorEvent>();
for (int a = 0; a < animatorEvents.Count; a++)
{
var hasEvent = false;
for (int i = 0; i < behaviours.Length; i++)
{
if (behaviours[i].HasEvent(animatorEvents[a].eventName))
{
behaviours[i].RegisterEvents(animatorEvents[a].eventName, animatorEvents[a].OnTriggerEvent);
if (animatorEvents[a].debug)
{
Debug.Log("<color=green>" + gameObject.name + " Register event : " + animatorEvents[a].eventName + "</color> in the " + animator.gameObject.name, gameObject);
}
hasValidBehaviours = true;
hasEvent = true;
}
}
if (!hasEvent && animatorEvents[a].debug)
{
Debug.LogWarning(animator.gameObject.name + " Animator doesn't have Event with name: " + animatorEvents[a].eventName, gameObject);
}
}
}
else
{
Debug.LogWarning("Can't Find Animator to register Events in " + gameObject.name + (getAnimatorInParent ? " Parent" : ""), gameObject);
}
}
}
public virtual void RemoveEvents()
{
if (!hasAnimator || !hasValidBehaviours)
{
return;
}
if (animatorEvents.Count > 0)
{
var animator = getAnimatorInParent ? GetComponentInParent<Animator>() : GetComponent<Animator>();
if (animator)
{
var behaviours = animator.GetBehaviours<Invector.vEventSystems.vAnimatorEvent>();
for (int a = 0; a < animatorEvents.Count; a++)
{
for (int i = 0; i < behaviours.Length; i++)
{
if (behaviours[i].HasEvent(animatorEvents[a].eventName))
{
behaviours[i].RemoveEvents(animatorEvents[a].eventName, animatorEvents[a].OnTriggerEvent);
if (animatorEvents[a].debug)
{
Debug.Log("<color=red>" + gameObject.name + " Remove event : " + animatorEvents[a].eventName + "</color> Of the " + animator.gameObject.name, gameObject);
}
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 393a4106eb54f894a900c48422883d15
timeCreated: 1542762980
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using UnityEngine;
public class vAnimatorIncreaseDecreaseValue : StateMachineBehaviour
{
public string targetFloat;
public bool decrease;
private float time;
public float speed = 1;
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (!decrease) time += Time.deltaTime * speed;
else time -= Time.deltaTime * speed;
animator.SetFloat(targetFloat, time);
}
// OnStateMove is called right after Animator.OnAnimatorMove()
//override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
//{
// // Implement code that processes and affects root motion
//}
// OnStateIK is called right after Animator.OnAnimatorIK()
//override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
//{
// // Implement code that sets up animation IK (inverse kinematics)
//}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 313cea8496c09c74aa3c474ed08d4a63
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using UnityEngine;
namespace Invector.Utils
{
public class vResetTrigger : StateMachineBehaviour
{
public bool resetOnEnter,resetOnExit;
public string trigger;
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if(resetOnEnter)
animator.ResetTrigger(trigger);
}
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (resetOnExit)
animator.ResetTrigger(trigger);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bddd5b9ffd2ac5f4abd68d6c9df44779
timeCreated: 1558124328
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
namespace Invector
{
public class vAnimatorSetBool : vAnimatorSetValue<bool>
{
[vHelpBox("Random Value between True and False")]
public bool randomEnter;
public bool randomExit;
protected override bool GetEnterValue()
{
return randomEnter ? UnityEngine.Random.Range(0,100)>50 : base.GetEnterValue();
}
protected override bool GetExitValue()
{
return randomExit ? UnityEngine.Random.Range(0, 100)>50 : base.GetExitValue();
}
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
//override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
//override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
//override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here
//override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here.
//override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 00fede628fd16c84893b0e6fb236264f
timeCreated: 1544029143
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
namespace Invector
{
public class vAnimatorSetFloat : vAnimatorSetValue<float>
{
[vHelpBox("Random Value between Default Value and Max Value")]
public bool randomEnter;
[vHideInInspector("randomEnter")]
public float maxEnterValue;
public bool randomExit;
[vHideInInspector("randomExit")]
public float maxExitValue;
[vHelpBox("Use this in <b>Random mode</b> to generat a rounded value")]
public bool roundValue;
[UnityEngine.Tooltip("Digits after the comma")]
[vHideInInspector("roundValue")]
public int roundDigits =1;
[UnityEngine.Tooltip("Invert number randomly")]
public bool randomInvert;
protected override float GetEnterValue()
{
var val = 0f;
if(randomEnter)
{
val = UnityEngine.Random.Range(base.GetEnterValue(), maxEnterValue);
if (roundValue) val =(float) System.Math.Round(val, roundDigits);
}
else val = base.GetEnterValue();
if (randomInvert)
{
if (UnityEngine.Random.Range(0, 100) > 50) val *= -1;
}
return val;
}
protected override float GetExitValue()
{
var val = 0f;
if (randomEnter)
{
val = UnityEngine.Random.Range(base.GetExitValue(), maxEnterValue);
if (roundValue) val = (float)System.Math.Round(val, roundDigits);
}
else val = base.GetExitValue();
if (randomInvert)
{
if (UnityEngine.Random.Range(0, 100) > 50) val *= -1;
}
return val;
}
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
//override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
//override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
//override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here
//override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here.
//override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3e7281fa362187f4a80ff9a5e86aedc5
timeCreated: 1544029143
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
namespace Invector
{
public class vAnimatorSetInt : vAnimatorSetValue<int>
{
vFisherYatesRandom random = new vFisherYatesRandom();
[vHelpBox("Random Value between Default Value and Max Value")]
public bool randomEnter;
[vHideInInspector("randomEnter")]
public int maxEnterValue;
public bool randomExit;
[vHideInInspector("randomExit")]
public int maxExitValue;
protected override int GetEnterValue()
{
return randomEnter ? random.Range(base.GetEnterValue(), maxEnterValue) : base.GetEnterValue();
}
protected override int GetExitValue()
{
return randomExit ? random.Range(base.GetExitValue(), maxExitValue) : base.GetExitValue();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4971f2abc3e4f6746b768f2ab57d497b
timeCreated: 1544029143
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using UnityEngine;
public class vAnimatorSetTrigger : StateMachineBehaviour
{
public bool setOnEnter, setOnExit;
public string trigger;
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (setOnEnter)
animator.SetTrigger(trigger);
}
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (setOnExit)
animator.SetTrigger(trigger);
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b0137783fa327dd49b5c6281d64d24e7
timeCreated: 1563411986
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using System;
using UnityEngine;
namespace Invector
{
[Serializable]
public abstract class vAnimatorSetValue<T> : StateMachineBehaviour where T : IConvertible
{
public string animatorParameter = "My Animator Parameter";
public bool setOnEnter;
[vHideInInspector("setOnEnter")]
public T enterValue;
public bool setOnExit;
[vHideInInspector("setOnExit")]
public T exitValue;
protected virtual T GetEnterValue()
{
return enterValue;
}
protected virtual T GetExitValue()
{
return exitValue;
}
override public sealed void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (setOnEnter)
{
if (typeof(T).Equals(typeof(int)))
animator.SetInteger(animatorParameter, (int)(object)GetEnterValue());
else if (typeof(T).Equals(typeof(float)))
animator.SetFloat(animatorParameter, (float)(object)GetEnterValue());
else if (typeof(T).Equals(typeof(bool)))
animator.SetBool(animatorParameter, (bool)(object)GetEnterValue());
}
}
override public sealed void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (setOnExit)
{
if (typeof(T).Equals(typeof(int)))
animator.SetInteger(animatorParameter, (int)(object)GetExitValue());
else if (typeof(T).Equals(typeof(float)))
animator.SetFloat(animatorParameter, (float)(object)GetExitValue());
else if (typeof(T).Equals(typeof(bool)))
animator.SetBool(animatorParameter, (bool)(object)GetExitValue());
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f4a2739c02b8e6848a989653d09be345
timeCreated: 1544029143
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
using UnityEngine;
namespace Invector.vEventSystems
{
public class vAnimatorTag : vAnimatorTagBase
{
public string[] tags = new string[] { "CustomAction" };
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
base.OnStateEnter(animator, stateInfo, layerIndex);
if (stateInfos != null)
{
for (int i = 0; i < tags.Length; i++)
{
for (int a = 0; a < stateInfos.Count; a++)
{
stateInfos[a].AddStateInfo(tags[i], layerIndex);
}
}
}
OnStateEnterEvent(tags.vToList());
}
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
base.OnStateUpdate(animator, stateInfo, layerIndex);
if (stateInfos != null)
{
for (int a = 0; a < stateInfos.Count; a++)
{
stateInfos[a].UpdateStateInfo(layerIndex, stateInfo.normalizedTime, stateInfo.shortNameHash);
}
}
}
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfos != null)
{
for (int i = 0; i < tags.Length; i++)
{
for (int a = 0; a < stateInfos.Count; a++)
stateInfos[a].RemoveStateInfo(tags[i], layerIndex);
}
}
base.OnStateExit(animator, stateInfo, layerIndex);
OnStateExitEvent(tags.vToList());
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d23a79fe8deb55a4fb192f4d8b417fea
timeCreated: 1519142239
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,145 @@
using System.Collections.Generic;
using UnityEngine;
namespace Invector.vEventSystems
{
public class vAnimatorTagAdvanced : vAnimatorTagBase
{
public enum vAnimatorEventTriggerType
{
AllByNormalizedTime, EnterStateExitByNormalized, EnterByNormalizedExitState, EnterStateExitState
}
[System.Serializable]
public class vAdvancedTags
{
public string tagName;
public vAnimatorEventTriggerType tagType = vAnimatorEventTriggerType.AllByNormalizedTime;
public Vector2 normalizedTime = new Vector2(0.1f, 0.8f);
private int loopCount;
public vAdvancedTags(string tag)
{
this.tagName = tag;
this.tagType = vAnimatorEventTriggerType.AllByNormalizedTime;
}
bool isEnter;
bool isExit;
public void UpdateEventTrigger(float normalizedTime, List<vAnimatorStateInfos> stateInfos, int layer, float speed = 1,bool looping= false, bool inExit = false, bool debug = false)
{
var normalizedTimeClamped = normalizedTime % 1;
if (!isEnter && !inExit && tagType != vAnimatorEventTriggerType.EnterStateExitByNormalized &&
tagType != vAnimatorEventTriggerType.EnterStateExitState && normalizedTimeClamped >= this.normalizedTime.x )
{
if (debug) Debug.Log("ADD TAG " + tagName + " in " + normalizedTime);
AddTag(stateInfos, layer);
}
if (!isExit && isEnter && tagType != vAnimatorEventTriggerType.EnterByNormalizedExitState &&
tagType != vAnimatorEventTriggerType.EnterStateExitState && (normalizedTimeClamped >= this.normalizedTime.y || inExit))
{
RemoveTag(stateInfos, layer);
if (debug) Debug.Log("REMOVE TAG " + tagName + " in " + normalizedTime);
}
if (looping && normalizedTime > loopCount + 1)
{
isEnter = false;
isExit = false;
loopCount++;
}
}
public void AddTag(List<vAnimatorStateInfos> stateInfos, int layer)
{
for (int i = 0; i < stateInfos.Count; i++)
stateInfos[i].AddStateInfo(tagName, layer);
isEnter = true;
}
public void RemoveTag(List<vAnimatorStateInfos> stateInfos, int layer)
{
for (int i = 0; i < stateInfos.Count; i++)
{
stateInfos[i].RemoveStateInfo(tagName, layer); isExit = true;
}
}
public void Init(List<vAnimatorStateInfos> stateInfos, int layer)
{
if(isEnter && !isExit)
{
RemoveTag(stateInfos, layer);
}
isEnter = false;
isExit = false;
loopCount = 0;
}
}
public bool debug;
public List<vAdvancedTags> tags = new List<vAdvancedTags>() { new vAdvancedTags("CustomAction") };
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
base.OnStateEnter(animator, stateInfo, layerIndex);
if (stateInfos != null)
{
for (int i = 0; i < tags.Count; i++)
{
tags[i].Init(stateInfos,layerIndex);
if (debug) Debug.Log("Init " + tags[i].tagName + " OnStateEnter ");
if (tags[i].tagType == vAnimatorEventTriggerType.EnterStateExitState || tags[i].tagType == vAnimatorEventTriggerType.EnterStateExitByNormalized)
{
if (debug) Debug.Log("ADD TAG " + tags[i].tagName + " OnStateEnter ");
tags[i].AddTag(stateInfos, layerIndex);
}
else
tags[i].UpdateEventTrigger(stateInfo.normalizedTime, stateInfos, layerIndex, animator.speed,stateInfo.loop, false, debug);
}
}
}
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfos != null)
{
for (int i = 0; i < tags.Count; i++)
{
if (tags[i].tagType != vAnimatorEventTriggerType.EnterStateExitState)
tags[i].UpdateEventTrigger(stateInfo.normalizedTime, stateInfos, layerIndex, animator.speed, stateInfo.loop, false, debug);
}
for (int a = 0; a < stateInfos.Count; a++)
{
stateInfos[a].UpdateStateInfo(layerIndex, stateInfo.normalizedTime, stateInfo.shortNameHash);
}
}
base.OnStateUpdate(animator, stateInfo, layerIndex);
}
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfos != null)
{
for (int i = 0; i < tags.Count; i++)
{
if (tags[i].tagType == vAnimatorEventTriggerType.EnterStateExitState || tags[i].tagType == vAnimatorEventTriggerType.EnterByNormalizedExitState)
{
if (debug) Debug.Log("REMOVE TAG " + tags[i].tagName + " OnStateExit ");
tags[i].RemoveTag(stateInfos, layerIndex);
}
else
{
tags[i].UpdateEventTrigger(stateInfo.normalizedTime, stateInfos, layerIndex, animator.speed, stateInfo.loop, true, debug);
}
}
}
base.OnStateExit(animator, stateInfo, layerIndex);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5f3b04f29aa5b134b99e94c78b296dcf
timeCreated: 1563393673
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
using System.Collections.Generic;
using UnityEngine;
namespace Invector.vEventSystems
{
public abstract class vAnimatorTagBase : StateMachineBehaviour
{
public delegate void OnStateTrigger(List<string> tags);
public List<vAnimatorStateInfos> stateInfos = new List<vAnimatorStateInfos>();
public event OnStateTrigger onStateEnter;
public event OnStateTrigger onStateExit;
public virtual void AddStateInfoListener(vAnimatorStateInfos stateInfo)
{
if (!stateInfos.Contains(stateInfo))
{
stateInfos.Add(stateInfo);
}
}
public virtual void RemoveStateInfoListener(vAnimatorStateInfos stateInfo)
{
if (stateInfos.Contains(stateInfo))
{
stateInfos.Remove(stateInfo);
}
}
protected virtual void OnStateEnterEvent(List<string> tags)
{
if (onStateEnter != null)
onStateEnter(tags);
}
protected virtual void OnStateExitEvent(List<string> tags)
{
if (onStateEnter != null)
onStateExit(tags);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: de3c236429d76fa4fb7d65e6e501f656
timeCreated: 1563393518
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,137 @@
using UnityEngine;
namespace Invector.vEventSystems
{
public class vAnimatorTagByParamenter : vAnimatorTag
{
public enum ParamenterType
{
Bool, Float, Int
}
public enum NumberCompare
{
Equals, Greater, Less
}
public string paramenterName;
public ParamenterType paramenterType;
[vCheckProperty("paramenterType", ParamenterType.Bool, hideInInspector = true)]
public bool boolValue;
[vCheckProperty("paramenterType", ParamenterType.Float, hideInInspector = true)]
public float floatValue;
[vCheckProperty("paramenterType", ParamenterType.Int, hideInInspector = true)]
public int intValue;
[vCheckProperty("paramenterType", ParamenterType.Bool, hideInInspector = true, invertResult = true)]
public NumberCompare compare;
[vReadOnly] public bool tagAdded;
vAnimatorParameter paramenter;
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (paramenter == null) paramenter = new vAnimatorParameter(animator, paramenterName);
///don't do anything
}
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
base.OnStateUpdate(animator, stateInfo, layerIndex);
CheckForParamenter(animator, layerIndex);
}
private void CheckForParamenter(Animator animator, int layerIndex)
{
if (paramenter.isValid)
{
bool isValid = false;
switch (paramenterType)
{
case ParamenterType.Float:
isValid = CompareNumber(floatValue, animator.GetFloat(paramenter), compare);
break;
case ParamenterType.Int:
isValid = CompareNumber(intValue, animator.GetInteger(paramenter), compare);
break;
case ParamenterType.Bool:
isValid = boolValue == animator.GetBool(paramenter);
break;
}
if (isValid != tagAdded)
{
tagAdded = isValid;
if (isValid)
{
AddTags(layerIndex);
}
else
{
RemoveTags(layerIndex);
}
}
}
}
void AddTags(int layerIndex)
{
if (stateInfos != null)
{
for (int i = 0; i < tags.Length; i++)
{
for (int a = 0; a < stateInfos.Count; a++)
{
stateInfos[a].AddStateInfo(tags[i], layerIndex);
}
}
}
}
void RemoveTags(int layerIndex)
{
if (stateInfos != null)
{
for (int i = 0; i < tags.Length; i++)
{
for (int a = 0; a < stateInfos.Count; a++)
{
stateInfos[a].RemoveStateInfo(tags[i], layerIndex);
}
}
}
}
bool CompareNumber(float a, float b, NumberCompare compare)
{
switch (compare)
{
case NumberCompare.Equals:
Debug.Log($"{b} == {a}");
return b == a;
case NumberCompare.Greater:
Debug.Log($"{b} > {a}");
return b > a;
case NumberCompare.Less:
Debug.Log($"{b} < {a}");
return b < a;
}
return false;
}
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (tagAdded)
{
tagAdded = false;
base.OnStateExit(animator, stateInfo, layerIndex);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 577d140dc31f50e4aaace33c11e23be5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using UnityEngine;
namespace Invector
{
public static partial class vAnimatorTags
{
[Tooltip("Use to lock the controller movement to use the root movement instead")]
public const string LockMovement = "LockMovement";
[Tooltip("Use to lock the controller rotation to use the root rotation instead")]
public const string LockRotation = "LockRotation";
[Tooltip("Use for Generic Actions like push lever, it will lock the players input, movement and rotation and use the animation root motion")]
public const string CustomAction = "CustomAction";
[Tooltip("Use to identify if this is a Airborne animation")]
public const string Airborne = "Airborne";
[Tooltip("Use to Ignore the Headtrack")]
public const string IgnoreHeadtrack = "IgnoreHeadtrack";
[Tooltip("Use to identify a Death animation")]
public const string Dead = "Dead";
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3a53c78ce94812c45a50fd08c068e33f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
using Invector;
using UnityEngine;
public class vChangeAnimatorUpdateMode : MonoBehaviour
{
public Animator animator;
private readonly AnimatorUpdateMode initialState = AnimatorUpdateMode.Fixed;
public void Reset()
{
animator = GetComponentInParent<Animator>();
}
private void Start()
{
if (!animator) animator = GetComponentInParent<Animator>();
}
public void ChangeToUnscaledTime()
{
if (Time.timeScale == 0)
{
vTime.useUnscaledTime = true;
animator.updateMode = AnimatorUpdateMode.UnscaledTime;
}
}
public void ChangeToAnimatePhysics()
{
animator.updateMode = AnimatorUpdateMode.Fixed;
vTime.useUnscaledTime = false;
}
public void ChangeToInitialState()
{
animator.updateMode = initialState;
vTime.useUnscaledTime =initialState== AnimatorUpdateMode.UnscaledTime ?true:false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 93dccd0079a44644690bde51cf65d442
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using UnityEngine;
namespace Invector.Utils
{
public class vSetAnimatorLayerWeight : MonoBehaviour
{
public Animator animator;
public int layer;
public float weight;
public float speed;
[Invector.vReadOnly]
protected float currentWeight;
private void Update()
{
currentWeight = Mathf.Lerp(currentWeight, weight, speed * Time.deltaTime);
animator.SetLayerWeight(layer, currentWeight);
}
public void SetWeight(float value)
{
weight = value;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c62b00526b41b3f49ba7c01b105e9733
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,126 @@
using UnityEngine;
namespace Invector.Utils
{
[vClassHeader("Set Animator Value", useHelpBox = true, helpBoxText = "Use this component to set animator value using events")]
public class vSetAnimatorValue : vMonoBehaviour
{
[vSelectableString("Set Float exemple", "ParamenterName,Float,1.0")]
[vSelectableString("Set Integer exemple", "ParamenterName,Int,1")]
[vSelectableString("Set Bool exemple", "ParamenterName,Bool,true")]
[vSelectableString("Set Trigger exemple", "ParamenterName,Trigger,Set")]
[vSelectableString("Reset Trigger exemple", "ParamenterName,Trigger,Reset")]
[vHelpBox("SetValueByExpression examples", vHelpBoxAttribute.MessageType.Info)]
[Tooltip("Target Animator to set value")]
public Animator targetAnimator;
[Tooltip("Target paramenter for normal methods\nDon't will be used when using SetValueByExpression method")]
public string targetParamenter;
[SerializeField, vReadOnly]
protected int paramenterHash;
enum ValueType
{
Float, Int, Bool, Trigger
}
public void SetTargetAnimator(Animator animator)
{
targetAnimator = animator;
}
public void SetTrigger()
{
targetAnimator.SetTrigger(paramenterHash);
}
public void ResetTrigger()
{
targetAnimator.ResetTrigger(paramenterHash);
}
public void SetBoolean(bool value)
{
targetAnimator.SetBool(paramenterHash, value);
}
public void SetInteger(int value)
{
targetAnimator.SetInteger(paramenterHash, value);
}
public void SetFloat(float value)
{
targetAnimator.SetFloat(paramenterHash, value);
}
public void SetTargetParamenter(string targetParamenter)
{
this.targetParamenter = targetParamenter;
}
public void SetValueByExpression(string expression)
{
string[] splited = expression.Split(',');
if (splited.Length < 3)
{
Debug.LogWarning($"Expression :<color=green>{expression}</color> does't match any valid expression");
return;
}
string parameterName = splited[0];
if (System.Enum.TryParse<ValueType>(splited[1], out ValueType valueType))
{
var value = splited[2];
bool setFail = false;
switch (valueType)
{
case ValueType.Bool:
if (System.Boolean.TryParse(value, out bool boolValue))
{
targetAnimator.SetBool(parameterName, boolValue);
}
else
{
setFail = true;
}
break;
case ValueType.Int:
if (System.Int32.TryParse(value, out int intValue))
{
targetAnimator.SetInteger(targetParamenter, intValue);
}
else
{
setFail = true;
}
break;
case ValueType.Float:
if (System.Double.TryParse(value, out double doubleValue))
{
targetAnimator.SetFloat(parameterName, (float)doubleValue);
}
else
{
setFail = true;
}
break;
case ValueType.Trigger:
if (value == "Set")
{
targetAnimator.SetTrigger(parameterName);
}
else if (value == "Reset")
{
targetAnimator.ResetTrigger(parameterName);
}
else
{
setFail = true;
}
break;
}
if (setFail)
{
Debug.LogWarning($"Expression :<color=green>{value}</color> does't match any valid value");
}
}
else
{
Debug.LogWarning($"Expression :<color=green>{splited[0]}</color> does't match any animator value");
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4bc693a7cefca084a80e8ad337098256
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
using UnityEngine;
using System.Collections.Generic;
namespace Invector
{
public class vTriggerSoundByState : StateMachineBehaviour
{
public GameObject audioSource;
public List<AudioClip> sounds;
public float triggerTime;
private vFisherYatesRandom _random;
private bool isTrigger;
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
isTrigger = false;
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfo.normalizedTime % 1 >= triggerTime && !isTrigger)
{
TriggerSound(animator, stateInfo, layerIndex);
}
else if (stateInfo.normalizedTime % 1 < triggerTime && isTrigger) isTrigger = false;
}
void TriggerSound(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (_random == null)
_random = new vFisherYatesRandom();
isTrigger = true;
GameObject audioObject = null;
if (audioSource != null)
audioObject = Instantiate(audioSource.gameObject, animator.transform.position, Quaternion.identity) as GameObject;
else
{
audioObject = new GameObject("audioObject");
audioObject.transform.position = animator.transform.position;
}
if (audioObject != null)
{
var source = audioObject.gameObject.GetComponent<AudioSource>();
var clip = sounds[_random.Next(sounds.Count)];
source.PlayOneShot(clip);
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ae6dcf6552bd02645a9ceb894d7a6cfa
timeCreated: 1461723406
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class vUseRootMotion : StateMachineBehaviour
{
// OnStateMove is called before OnStateMove is called on any state inside this state machine
override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.ApplyBuiltinRootMotion();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 26c66b0e3fe82a44ea5f4ea510c6de6c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a01de65492e63e44e924463c625ed812
folderAsset: yes
timeCreated: 1544048860
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5bdf3813e1132bd4bbb17e142b6b37f5
folderAsset: yes
timeCreated: 1544055025
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 252cb1b4e9bfd5044b0dfd9a6c30728e
timeCreated: 1519157384
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 08c6c4ad686732946958f3b63923829e
timeCreated: 1469207365
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 795f336bc230ef247b0206beca796d22
timeCreated: 1498054874
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: cca213a8eff642b42b00c303fcdfb5e0
timeCreated: 1527529455
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 557f303a83b630b4eb322ab5446593b5
timeCreated: 1498054874
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d55fa4bb70d62f04baf64b394f5110c3
timeCreated: 1555010343
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e348f117cf4edaf479decaeed6efdbef
timeCreated: 1498693563
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4fe287b7356c9cd4ab0a38a8d891f548
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e34712f7edd1c1844b053d9b4ed9f4da
timeCreated: 1518738141
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2ed1909ee22be2c4ca004bf81f3e2276
timeCreated: 1530303471
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 096a2b9fad602c041a4ce6cd5ee15d01
timeCreated: 1529518712
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e6ae96fdc6b575249a94367b25cefb95
timeCreated: 1529519547
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad78f56404d97374c84c434f24b141c8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f405ef569ee722147b66f6e87bc448ef
timeCreated: 1529518590
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9010aa46101362a488c76277e19623e0
timeCreated: 1529518614
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e6ac28d2168f93e43a0b2454325486c0
timeCreated: 1529518913
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a86e5138f69f693439455d5eff277713
timeCreated: 1529518900
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 57d05196792a06748ad8042cdf0fc573
timeCreated: 1555009967
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 44980ddaec236754c96bccd5b9af9d05
timeCreated: 1529518700
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8615c74e7fb0c84409242a7d9420676b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7f0d65062c21c764ca1972dd44c8a034
timeCreated: 1530303202
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7075cc27664e39b4eaa93548f350b329
folderAsset: yes
timeCreated: 1558643097
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b8e71356e2d292b489dd4dd276e40013
folderAsset: yes
timeCreated: 1558679563
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 783e14f694a800d49b30a1cb1fced871
folderAsset: yes
timeCreated: 1558653810
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 65f90c9aeb55c284db8781274114886a
folderAsset: yes
timeCreated: 1558664445
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d9f809d0fb9c3cc4c8b70e6e5b90075a
folderAsset: yes
timeCreated: 1558969115
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: No Name
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 65d5441e6a4c7d04287723684491347e
timeCreated: 1558969115
licenseType: Store
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More