Skip to content

Commit 54545a9

Browse files
committed
Added variable base classes
1 parent fdde3ea commit 54545a9

File tree

13 files changed

+141
-0
lines changed

13 files changed

+141
-0
lines changed

Assets/AdncAnimatorVariableStates.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorVariableStates/Scripts.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorVariableStates/Scripts/Variables.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace Adnc.AnimatorVariables.Variables {
6+
public abstract class VarBase<T> {
7+
protected const string VALUE_TOOLTIP = "The value that will be set when SetValue is called";
8+
9+
[Tooltip("Name of the variable")]
10+
public string name;
11+
12+
public virtual bool IsValid {
13+
get { return !string.IsNullOrEmpty(name); }
14+
}
15+
16+
public abstract void SetValue (Animator animator);
17+
18+
public abstract T GetValue (Animator animator);
19+
}
20+
}

Assets/AdncAnimatorVariableStates/Scripts/Variables/VarBase.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using UnityEngine;
2+
3+
namespace Adnc.AnimatorVariables.Variables {
4+
[System.Serializable]
5+
public class VarBool : VarBase<bool> {
6+
[Tooltip(VALUE_TOOLTIP)]
7+
public bool value;
8+
9+
public override void SetValue (Animator animator) {
10+
animator.SetBool(name, value);
11+
}
12+
13+
public override bool GetValue (Animator animator) {
14+
return animator.GetBool(name);
15+
}
16+
}
17+
}

Assets/AdncAnimatorVariableStates/Scripts/Variables/VarBool.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using UnityEngine;
2+
3+
namespace Adnc.AnimatorVariables.Variables {
4+
[System.Serializable]
5+
public class VarFloat : VarBase<float> {
6+
[Tooltip(VALUE_TOOLTIP)]
7+
public float value;
8+
9+
public override void SetValue (Animator animator) {
10+
animator.SetFloat(name, value);
11+
}
12+
13+
public override float GetValue (Animator animator) {
14+
return animator.GetFloat(name);
15+
}
16+
}
17+
}

Assets/AdncAnimatorVariableStates/Scripts/Variables/VarFloat.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using UnityEngine;
2+
3+
namespace Adnc.AnimatorVariables.Variables {
4+
[System.Serializable]
5+
public class VarInt : VarBase<int> {
6+
[Tooltip(VALUE_TOOLTIP)]
7+
public int value;
8+
9+
public override void SetValue (Animator animator) {
10+
animator.SetInteger(name, value);
11+
}
12+
13+
public override int GetValue (Animator animator) {
14+
return animator.GetInteger(name);
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)