Object motion callbacks added
QQ1273459693 opened this issue · comments
It would be perfect if you could implement a callback after each movement, e.g., after object A moves to position B, I'll move A to position C again, and then I'll call the callback after each movement.
Bassically its:
- Move transform A From position A to potition B for x seconds
- Wait x seconds
- Call unityevent
- Move transform A From position B to potition C y seconds
- Wait y seconds
- Call unityevent
Instead of callback in each sequence, you can add an event that calls the function you want to call.
Or you can also do it with code like this if you don't want to add it in the inspector. (I didnt make a clear documentation for it tho):
using UnityEngine;
public class CallbackTest : MonoBehaviour
{
// Assign the AnimationUI component in the inspector
[SerializeField] AnimationUI animationUI;
void Start()
{
animationUI.AnimationSequence[2].Event.AddListener(AfterAMoveToB);
animationUI.AnimationSequence[5].Event.AddListener(AfterAMoveToC);
}
void AfterAMoveToB()
{
Debug.Log("Callback After A move to B");
}
void AfterAMoveToC()
{
Debug.Log("Callback After A move to C");
}
}
Another alternative is to add multiple AnimationUI component. Then look at the Readme.md and use the AddFunctionAtEnd
to each animation. Make sure the second one has wait sequence.