Slate Forums › Support › Have any way to know I click Stop Button ?
I want to do below things..
1, Destroy Object in OnReverse() called by click Stop Button
2, Do not Destroy Object, just reset data in OnReverse() called by not click Stop Button
But, I have no idea to know OnReverse() is called by click stop button or not….
Hey,
The closest thing to what you are after, could be done by checking if ‘root.currentTime == 0’. When the Stop button in the editor is clicked or the cutscene is anyhow rewinded, the cutscene is sampled at time 0.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
namespace Slate.ActionClips{ public class TestClip : ActorActionClip { protected override void OnReverse(){ if (root.currentTime == 0){ Debug.Log("Cutscene Reverse"); } else { Debug.Log("Clip Reverse"); } } } } |
Let me know if that works for you.
Join us on Discord: https://discord.gg/97q2Rjh
I want to do is create GameObject once between click play button many times and click stop button once
1, create a GameObject when click play button first
2, do something like move, rotate…etc for GameObject when playing
3, click play button again when end and do not click stop button, in this case, GameObject just reset data, not need to destroy
4, click stop button and destroy GameObject
If check is
void OnReverse()
{
if (root.currentTime == 0) destroy GameObject;
else GameObject reset data;
}
There is a problem in step 3, OnReverse will be called and currentTime == 0, so GameObject will be destroyed..
Maybe add a global flag like isClickStop ?, set true when click stop button, set false when click play button
Then check change to
void OnReverse()
{
if (Cutscene.isClickStop) Destroy GameObject;
else GameObject reset data;
}