I’d like to have animation on the pause screen, so using Time.timeScale isn’t desirable. Is there any other way to pause the game, perhaps by layer or group?
Define a boolean variable and check as below where you want to pause which method.
if(!isGamePause)
DoSomething();
I hope that will help you and sorry for my English
You could create a class inherited from Monobehaviour with a custom update function running on coroutines and realtime. Then, you can easily pause anything inheriting from it. Example in C# :
public class TimedMonoBehaviour : MonoBehaviour
{
protected float timeScale = 1f;
protected bool paused = false;
protected deltaTime{ get; private set; } // Can be used in sub-classes
private float lastUpdate = 0f;
private IEnumerator Start()
{
while( Application.isPlaying )
{
deltaTime = (Time.realtimeSinceStartup - lastUpdate) * timeScale;
lastUpdate = Time.realtimeSinceStartup;
// Might be problematic to unpause,
// inputs shouldn't be in TimedUpdate.
if( !paused )
TimedUpdate();
yield return null;
}
}
protected virtual void TimedUpdate(){} // Replace Update
}
And then, when you create a new script
public class SomeStuff : TimedMonoBehaviour
{
protected override void TimedUpdate()
{
transform.Translate( new Vector3( deltaTime * 10f, 0f, 0f ) );
}
}
I haven’t tested any of it, so be careful. Physic won’t be affected at all though.