Skip to content

Commit 2d6839e

Browse files
committed
Merge branch 'release/1.0'
2 parents 67f5c28 + 632dc85 commit 2d6839e

File tree

193 files changed

+3679
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+3679
-3
lines changed

Assets/AdncAnimatorHelpers.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorHelpers/Editor.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorHelpers/Editor/Scripts.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorHelpers/Editor/Scripts/CustomEditors.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorHelpers/Editor/Scripts/CustomEditors/AnimatorPlayback.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEditor;
4+
using UnityEngine;
5+
6+
namespace Adnc.AnimatorHelpers.Editors.CustomEditors {
7+
[CustomEditor(typeof(AnimatorPlayback))]
8+
public class AnimatorPlaybackEditor : Editor {
9+
private SortableListAnimatorVariable _listBools;
10+
private SortableListAnimatorVariable _listFloats;
11+
private SortableListAnimatorVariable _listInts;
12+
private SortableListAnimatorVariable _listTriggers;
13+
14+
private void OnEnable () {
15+
_listBools = new SortableListAnimatorVariable(this, "bools", "Set Bools");
16+
_listFloats = new SortableListAnimatorVariable(this, "floats", "Set Floats");
17+
_listInts = new SortableListAnimatorVariable(this, "ints", "Set Ints");
18+
_listTriggers = new SortableListAnimatorVariable(this, "triggers", "Set Triggers");
19+
}
20+
21+
public override void OnInspectorGUI () {
22+
serializedObject.Update();
23+
24+
_listBools.Update();
25+
_listFloats.Update();
26+
_listInts.Update();
27+
_listTriggers.Update();
28+
29+
var propWait = serializedObject.FindProperty("waitForCondition");
30+
EditorGUILayout.PropertyField(propWait);
31+
32+
if (propWait.boolValue) {
33+
var propCondition = serializedObject.FindProperty("conditions");
34+
EditorGUILayout.PropertyField(propCondition, true);
35+
}
36+
37+
serializedObject.ApplyModifiedProperties();
38+
}
39+
}
40+
}

Assets/AdncAnimatorHelpers/Editor/Scripts/CustomEditors/AnimatorPlayback/AnimatorPlaybackEditor.cs.meta

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using Adnc.Utility.Editors;
4+
using UnityEditor;
5+
using UnityEngine;
6+
7+
namespace Adnc.AnimatorHelpers.Editors.CustomEditors {
8+
public class SortableListAnimatorVariable : SortableListBase {
9+
public SortableListAnimatorVariable (Editor editor, string property, string title) : base(editor, property, title) {
10+
_list.drawElementCallback = (rect, index, active, focused) => {
11+
var element = _serializedProp.GetArrayElementAtIndex(index);
12+
var propName = element.FindPropertyRelative("name");
13+
var propValue = element.FindPropertyRelative("value");
14+
15+
rect.height -= EditorGUIUtility.standardVerticalSpacing;
16+
17+
if (propValue != null) {
18+
var col1 = rect;
19+
col1.width /= 2;
20+
col1.width -= EditorGUIUtility.standardVerticalSpacing;
21+
EditorGUI.PropertyField(col1, propName, new GUIContent());
22+
23+
var col2 = col1;
24+
col2.x += col1.width + EditorGUIUtility.standardVerticalSpacing;
25+
EditorGUI.PropertyField(col2, propValue, new GUIContent());
26+
} else {
27+
EditorGUI.PropertyField(rect, propName, new GUIContent());
28+
}
29+
};
30+
}
31+
}
32+
}
33+

Assets/AdncAnimatorHelpers/Editor/Scripts/CustomEditors/AnimatorPlayback/SortableListAnimatorVariable.cs.meta

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorHelpers/Editor/Testing.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorHelpers/Editor/Testing/AnimatorPlayback.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
using Adnc.AnimatorHelpers.Conditions;
2+
using Adnc.AnimatorHelpers.Variables;
3+
using Adnc.Utility.Testing;
4+
using NUnit.Framework;
5+
using UnityEngine;
6+
using Object = UnityEngine.Object;
7+
8+
namespace Adnc.AnimatorHelpers.Editors.Testing {
9+
public class TestAnimatorPlayback : TestBase {
10+
private const string ANIMATOR_STUB_LOC = "AnimatorTesting/AnimatorStub";
11+
12+
private AnimatorPlayback _playback;
13+
private Animator _anim;
14+
15+
[SetUp]
16+
public void SetupAnimatorPlayback () {
17+
_playback = ScriptableObject.CreateInstance<AnimatorPlayback>();
18+
var stub = Resources.Load<GameObject>(ANIMATOR_STUB_LOC);
19+
_anim = Object.Instantiate(stub).GetComponent<Animator>();
20+
}
21+
22+
[TearDown]
23+
public void TeardownAnimatorPlayback () {
24+
Object.DestroyImmediate(_anim.gameObject);
25+
_playback = null;
26+
_anim = null;
27+
}
28+
29+
[Test]
30+
public void StubBoolIsFalse () {
31+
Assert.IsFalse(_anim.GetBool("bool"));
32+
}
33+
34+
[Test]
35+
public void StubFloatIsZero () {
36+
Assert.IsTrue(Mathf.Abs(_anim.GetFloat("float")) < 0.1f);
37+
}
38+
39+
[Test]
40+
public void StubIntIsZero () {
41+
Assert.IsTrue(_anim.GetInteger("int") == 0);
42+
}
43+
44+
[Test]
45+
public void PlaySetsAnimatorBool () {
46+
_playback.bools.Add(new VarBool {
47+
name = "bool",
48+
value = true
49+
});
50+
51+
_playback.Play(_anim);
52+
53+
Assert.IsTrue(_anim.GetBool("bool"));
54+
}
55+
56+
[Test]
57+
public void PlaySetsAnimatorFloat () {
58+
_playback.floats.Add(new VarFloat {
59+
name = "float",
60+
value = 1
61+
});
62+
63+
_playback.Play(_anim);
64+
65+
Assert.AreEqual(_anim.GetFloat("float"), 1);
66+
}
67+
68+
[Test]
69+
public void PlaySetsAnimatorInt () {
70+
_playback.ints.Add(new VarInt {
71+
name = "int",
72+
value = 1
73+
});
74+
75+
_playback.Play(_anim);
76+
77+
Assert.AreEqual(_anim.GetInteger("int"), 1);
78+
}
79+
80+
[Test]
81+
public void IsConditionMetTrueWithNoAnimatorNull () {
82+
Assert.IsTrue(_playback.IsConditionsMet(null));
83+
}
84+
85+
[Test]
86+
public void IsConditionMetIsTrueWithNoConditions () {
87+
_playback.conditions.RemoveAt(0);
88+
Assert.IsTrue(_playback.IsConditionsMet(_anim));
89+
}
90+
91+
[Test]
92+
public void IsConditionMetFalseWhenConditionsNotMet () {
93+
_playback.conditions.RemoveAt(0);
94+
_playback.conditions.Add(new Condition {
95+
compareValues = OperatorAll.AreEqual,
96+
variableBool = new VarBool {
97+
name = "bool",
98+
value = true
99+
},
100+
variableType = ConditionVarType.Bool
101+
});
102+
103+
Assert.IsFalse(_playback.IsConditionsMet(_anim));
104+
}
105+
106+
[Test]
107+
public void IsConditionMetTrueWhenConditionsAreMet () {
108+
_playback.conditions.RemoveAt(0);
109+
_playback.conditions.Add(new Condition {
110+
compareValues = OperatorAll.AreEqual,
111+
variableBool = new VarBool {
112+
name = "bool",
113+
value = true
114+
},
115+
variableType = ConditionVarType.Bool
116+
});
117+
118+
_anim.SetBool("bool", true);
119+
120+
Assert.IsTrue(_playback.IsConditionsMet(_anim));
121+
}
122+
}
123+
}

Assets/AdncAnimatorHelpers/Editor/Testing/AnimatorPlayback/TestAnimatorPlayback.cs.meta

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorHelpers/Examples.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AdncAnimatorHelpers/Examples/Default.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)