Skip to content

Commit

Permalink
Adjust methodcalls to animationerror enum.
Browse files Browse the repository at this point in the history
  • Loading branch information
MathewHDYT committed Nov 20, 2021
1 parent 4954551 commit 75b4242
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Example Project/Assets/Scripts/AnimationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum AnimationError {
/// <param name="startTime">Time we want to start the animation from.</param>
/// <param name="layer">Layer we find the given animation name on.</param>
/// <returns>AnimationError, showing wheter and how playing the file failed.</returns>
private AnimationError PlayAnimation(Animator animator, string newAnimation, float delayTime = 0.0f, float startTime = 0.0f, int layer = 0) {
public AnimationError PlayAnimation(Animator animator, string newAnimation, float delayTime = 0.0f, float startTime = 0.0f, int layer = 0) {
AnimationError message = AnimationError.OK;

// Fetch the current Animation clips information for the base layer.
Expand Down
22 changes: 13 additions & 9 deletions Example Project/Assets/Scripts/MethodCalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,33 @@ private void Start() {
}

public void PlayAnimationClicked() {
AnimationManager.AninmationError error = am.PlayAnimation(animator, inputField.text);
output.text = GetStringFromError(error);
AnimationManager.AnimationError err = am.PlayAnimation(animator, inputField.text);
output.text = GetStringFromError(err);
}

public void GetCurrentAnimationLengthClicked() {
float length = am.GetCurrentAnimationLength(animator);
output.text = "Length of the currently playing animation in seconds: " + length;
}

private string GetStringFromError(AninmationManager.AnimationError error) {
switch (error) {
private string GetStringFromError(AnimationManager.AnimationError err) {
string warning = "";

switch (err) {
case AnimationManager.AnimationError.OK:
// No Message
return;
warning = "Succesfully executed playing animation.";
break;
case AnimationManager.AnimationError.ALREADY_PLAYING:
// No Message
return;
warning = "Method is already playing.";
break;
case AnimationManager.AnimationError.DOES_NOT_EXIST:
warning = "Given Animation Name does not exist on the given Animator.";
break;
default:
warning = "Given AnimatonError State not defined.";
// Invalid AnimationManager.AnimationError argument.
break;
}

return warning;
}
}
6 changes: 3 additions & 3 deletions Example Project/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"dependencies": {
"com.unity.collab-proxy": "1.7.1",
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.11",
"com.unity.ide.vscode": "1.2.3",
"com.unity.test-framework": "1.1.27",
"com.unity.ide.visualstudio": "2.0.12",
"com.unity.ide.vscode": "1.2.4",
"com.unity.test-framework": "1.1.30",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.4.8",
"com.unity.ugui": "1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions Example Project/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.11",
"version": "2.0.12",
"depth": 0,
"source": "registry",
"dependencies": {
Expand All @@ -35,7 +35,7 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.vscode": {
"version": "1.2.3",
"version": "1.2.4",
"depth": 0,
"source": "registry",
"dependencies": {},
Expand All @@ -49,7 +49,7 @@
"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.27",
"version": "1.1.30",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down
5 changes: 4 additions & 1 deletion Example Project/ProjectSettings/EditorBuildSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes: []
m_Scenes:
- enabled: 1
path: Assets/Scenes/Main.unity
guid: 9fc0d4010bbf28b4594072e72b8655ab
m_configObjects: {}

0 comments on commit 75b4242

Please sign in to comment.