DhafinFawwaz / Unity-AnimationUI

Usefull Unity tool for animating UI with just drag and drop
MIT License
318 stars 33 forks source link
animation animation-library ui ui-library unity unity-editor unity-package

Logo

AnimationUI

AnimationUI is a unity tool to create UI animation easily with no code. You can simply drag and drop to create some smooth UI animation. There are some option that you can set such as the easing, duration, etc. It basically consist of a component that has an array of sequence that has an array of task. This may be special for UI, but it's also possible to animate values for non UI component like transform. You can also make a custom sequence for non UI component with UnityEvent including the dynamic one. Adding function to call at certain time or at the end of animation is also possible with code.

🕹️ Demo Preview

✨ Features

📘 Instruction

Instruction 1

Instruction 2

Instruction 3

Instruction 4

Instruction 5

Instruction 6

Instruction 7

🔍 API Reference

Get the reference by

using DhafinFawwaz.AnimationUILib;

public class Something : MonoBehaviour
{
    AnimationUI _animationUI;
    void DoSomething()
    {
        _animationUI.Play();
    }
}

🔗 Syntax

Methods Description
Play() Play the animation
PlayReversed() Play the animation but reversed. Usefull to go back from a certain menu quickly.
AddFunctionAt(float time, Action func) Add a function to be called at a certain time after the AnimationUI.Play() is called
Member Properties Type Description
OnAnimationEnded Action Callback when the latest wait sequence is finished. It's intended like this so that you also have an option for this case and not just at the very end of the whole sequences. If you want to make it get called at the end of the whole sequences, you can either call AddFunctionAt(_animationUI.TotalDuration, func) or just add another wait sequence as the last sequence in the inspector
Static Properties Type Description
OnSetActiveAllInput Action<bool> Play the animation
OnSetActiveAllInput Action<bool> Play the animation
OnPlaySoundByFile Action<AudioClip> Play the animation but reversed.
OnPlaySoundByIndex Action<int> Play the animation but reversed.

There's still no proper way to disable all input so if you also want to disable input other than mouse and touch, please modify AnimationUICustomizable.cs. You can also subscribe the static event of AnimationUI which are OnSetActiveAllInput, OnPlaySoundByFile, or OnPlaySoundByIndex to change its behaviour. Example of how to achieve this is in the Demo folder which is AudioManager.cs. Most of the variable in the Sequence class is modifiedable, so it's possible to change the values of _animationUI.AnimationSequence[MyIndex].MyVariableName on runtime.

📖 Examples

Play the animation, call LoadSceneWithLoadingBar() after animation finished.

_animationUI.OnAnimationEnded += LoadSceneWithLoadingBar;
_animationUI.Play();

Subscribe to customizable AnimationUI events.

void OnEnable()
{
    AnimationUI.OnSetActiveAllInput += SetActiveAllInput
    AnimationUI.OnPlaySoundByFile += PlaySoundByFile
    AnimationUI.OnPlaySoundByIndex += PlaySoundByIndex
}
void OnDisable()
{
    AnimationUI.OnSetActiveAllInput -= SetActiveAllInput
    AnimationUI.OnPlaySoundByFile -= PlaySoundByFile
    AnimationUI.OnPlaySoundByIndex -= PlaySoundByIndex
}
void SetActiveAllInput(bool isActive)
{
    Debug.Log("SetActive");
}
void PlaySoundByFile(AudioClip clip)
{
    Debug.Log("Playing " + clip.name);
}
void PlaySoundByIndex(int index)
{
    Debug.Log("Playing clip at index " + index.ToString());
}

📃 Note

📝 License

MIT