Heyas
My game has a lot of scene switching. I wanted an onscreen timer to run throughout the game as there is a time limit to play the game within before it restarts you at the beginning again. I managed to find some tips on the forum to create the timer using a Global Variable integer and displaying on screen via a Menu Label.
The timer works and shows on screen however the issue is, as soon as you change scenes, the timer stops working. It stays on screen, but the numbers stop increasing. It's like the actionlist stops working once the scene has been changed.
I have the Global timer actionlist set as the "Actionlist on start game" under Cutscene Settings which I assume is what triggers the actionlist in the first place, but perhaps it doesn't keep that action list going after a scene change? I'm not sure. Any help would be great.
Using Unity 2017.3.0f3 and AC 1.60.7
Thanks
Comments
For technical reasons, ActionLists cannot survive scene changes. You can re-run the ActionList via each scene's OnStart cutscene field, which is listed in the Scene Manager.
However, if all you're doing in the list is updating a variable every X seconds, it might be easier to just do it in a script, i.e:
http://pasteall.org/806190/csharp
Paste that in a C# script named TimerExample, and add it to your starting scene. It'll survive scene changes because its marked as DontDestroyOnLoad.
You can then use the Object: Call event Action on it to trigger its StartTimer and StopTimer methods as necessary. It'll link to an Integer variable with an ID of 0 (you can change the number in the Inspector), and will increase its value by 1 every 1 second. You can change these to suit as necessary.