Closed bitbuilders closed 5 years ago
Hi @bitbuilders Thank you for your cool PR. However, UIEffect should focus only on “applying visual effects to UI elements”.
Your feature does not depend on UIEffect and can control all game objects. You should implement it as another plugin.
Your feature does not depend on UIEffect and can control all game objects. You should implement it as another plugin.
That makes sense, and I had a hunch that would be the case. No problem, I got a lot of worth just out of looking through your architecture and shaders.
Very cool project!
I'll probably close the pull request in the near future.
I thought it would be cool to add the ability to animate UI, and make your package a one-stop-shop for most things UI related. It was a pretty fun task, so that alone made it worth it.
It's not super complicated to use, but in short, you can call the Animate(string) function on any UIEffect script and pass it an animation Id, and it will perform that animation.
The animation Id comes from a AnimatorControllerList ScriptableObject. And this ScriptableObject can be located in any folder named "Resources" (yes it is loaded in at runtime). It must be named "AnimatorControllerList". So all you have to do to create a new animation to call, is give it an Id, supply it any AnimatorController that holds the animations you want, and state if it has one or multiple clips (either 1 or 2 clips). With that done, all you need to do is call Animate(string animationId) and pass in the Id for the new animation you made.
The AnimatorController needs be structured in a special way. All controllers must have a "Start" and "Stop" trigger. If your controller only has one clip, you will need to make sure it can transition back to an idle state. If you want to call Animate(string) lots of times, make sure "Stop" can act as an override to go back to idle. Here is an example of how I do it:
For controllers with multiple clips (2 clips), "Start" will play the first clip, and then linger until "Stop" is called, but after "Stop" it will go back to Idle. Here is an example of how I used multiple clips:
Keep in mind, the boolean "MultipleClips" in the AnimatorControllerList ScriptableObject should be set to false for my first example, and true for my second.
As far as how to create the animation clips, that's all up to you! It can be whatever you want. In my examples, I just do some simple rotation and scaling.
Feel free to make changes to it as you see fit. I realize this isn't a perfect solution, but I feel like it can be pretty useful.