Skip to content

Commit 1a373df

Browse files
authored
Adjust documentation to the AnimationError Ennum
1 parent ceddfc7 commit 1a373df

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Used to simply play animations without having to create transitions, while givin
1515
- [Installation](#installation)
1616
- [Documentation](#documentation)
1717
- [Reference to Animation Manager Script](#reference-to-animation-manager-script)
18+
- [Possible Errors](#possible-errors)
1819
- [Inspiration](#inspiration)
1920
- [Public accesible methods](#public-accesible-methods)
2021
- [Play Animation method](#play-animation-method)
@@ -75,6 +76,14 @@ private void Start() {
7576
}
7677
```
7778

79+
## Possible Errors
80+
81+
| **ID** | **CONSTANT** | **MEANING** |
82+
| -------| ------------------------------| -----------------------------------------------------------------------------------------------|
83+
| 0 | SUCCESS | Method succesfully executed |
84+
| 1 | ALREADY_PLAYING | The given animation is already playing currently |
85+
| 2 | DOES_NOT_EXIST | Given animation does not exist on the given animator or layer |
86+
7887
## Inspiration
7988
The creation of this Animation Manager has been inspired by the [Escaping Unity Animator HELL](https://youtu.be/nBkiSJ5z-hE) video.
8089

@@ -83,7 +92,7 @@ This section explains all public accesible methods, especially what they do, how
8392

8493
### Play Animation method
8594
**What it does:**
86-
Starts playing the choosen animation if possible.
95+
Starts playing the choosen animation if possible and returns an AnimationError (see [Possible Errors](#possible-errors)), showing wheter and how playing the animation failed.
8796

8897
**How to call it:**
8998
- ```Animator``` is the animator the given animation is contained in
@@ -97,15 +106,27 @@ Animator animator = gameObject.GetComponent<Animator>();
97106
string newAnimation = "Player_attack";
98107
int layer = 0;
99108
float startTime = 0.0f;
100-
am.PlayAnimation(animator, newAnimation, layer, startTime);
109+
AnimationManager.AninmationError err = am.PlayAnimation(animator, newAnimation, layer, startTime);
110+
if (err != AnimationManager.AninmationError.OK) {
111+
Debug.Log("Playing animation failed with error id: ", err);
112+
}
113+
else {
114+
Debug.Log("Playing animation successful");
115+
}
101116
```
102117

103118
Alternatively you can call the methods with less paramters as some of them have default arguments.
104119

105120
```csharp
106121
Animator animator = gameObject.GetComponent<Animator>();
107122
string newAnimation = "Player_attack";
108-
am.PlayAnimation(animator, newAnimation);
123+
AnimationManager.AninmationError err = am.PlayAnimation(animator, newAnimation);
124+
if (err != AnimationManager.AninmationError.OK) {
125+
Debug.Log("Playing animation failed with error id: ", err);
126+
}
127+
else {
128+
Debug.Log("Playing animation successful");
129+
}
109130
```
110131

111132
**When to use it:**

0 commit comments

Comments
 (0)