Hello again. I am making a bunch of custom sequencer commands and got in a bit of an issue with one function.
I have a camera zoom function in an external file. I created a custom sequencer file and will call the zoom function from there. However I am not sure how to call the Stop() function after the zoom has finished.
I want to somehow call the Stop() function from the external file, after the zoom has finished. Though I am not quite sure how to achieve that... Do I somehow access the sequencer file and then call Stop() when the zoom finishes, or do I make a event or message inside the sequencer file so it waits for the zoom to finish?
Custom sequence Stop()
Re: Custom sequence Stop()
Hi,
It would be best to use an event, message, or callback. For example:
and:
I glided over some other code that your ExternalZoomScript will certainly need, but hopefully that gets the idea across. If not, let me know if you have any questions.
It would be best to use an event, message, or callback. For example:
Code: Select all
public class SequencerCommandZoom : SequencerCommand
{
void Awake()
{
ExternalZoomScript.instance.Zoom(Stop);
}
}
Code: Select all
public class ExternalZoomScript : MonoBehaviour
{
...
public void Zoom(System.Action callbackWhenDone)
{
StartCoroutine(ZoomCoroutine(callbackWhenDone));
}
IEnumerator ZoomCoroutine(System.Action callbackWhenDone)
{
//... your code here to zoom ...
// When done, call the callback:
callbackWhenDone();
}
}
-
- Posts: 41
- Joined: Mon Jul 19, 2021 11:27 am
Re: Custom sequence Stop()
That did it perfectly. I never would have thought that was the way to do it. Thanks again !
Re: Custom sequence Stop()
Glad I could help!