N
N
nuclear_kote2020-01-12 00:28:33
Unity
nuclear_kote, 2020-01-12 00:28:33

How to implement active pause?

I saw a pause solution with Time.timeScale = 0, but in theory it’s not very suitable for an active pause, because the camera and gui should remain working

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
I_GRIN_I, 2020-01-14
@nuclear_kote

You can create a class that inherits from MonoBehaviour, let's call it MonoBehaviourPaused, add protected bool IsPause to it, and check this property in the necessary checks. This way you can pause individual components at any time. You can also add PauseManager, create the SetPause method in it, as well as the IsPauseGlobal variable, and add a static List ActiveList to MonoBehaviourPaused, as well as 2 OnEnable and OnDisable methods, in OnEnable you can check for IsPauseGlobal and set IsPause, as well as add this to static sheet, and in OnDisable to remove from this sheet. In the SetPause method in PauseManager, you go through the MonoBehaviourPaused.ActiveList sheet and set IsPause to everyone, so you can set IsPause to everyone in one line, and only active components will be set.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question