0
votes

I'm working on a mobile game and the scene contains:

  • 3 different gameObjects- each contains a script to a static class-singleton (3 classes total)
  • 20 gameObject prefabs with properties scripts
  • 1 image

What do I need to serialize, when I get an incoming call for example?

By reading the Unity documentation, I can see that there is a built in serialization, is that true?

My questions are:

  1. Can I serialize the 3 singleton classes? (one of them is the game manager) I thought that I can't serialize static classes
  2. Does unity use the built-in serialization to store info about the prefab's transform, and other components attached like AudioSource properties, scripts and animation
  3. What happens if the animation is pausing when in the middle of playing?

I don't want to lose critical info when pausing a game and starting again.

1

1 Answers

2
votes

For 1. and 2.:

Typically, you shouldn't serialize classes like your GameManager, or components like Transform. Instead, serialize the values that define their state. For example, you can serialize position, rotation, and scale (which are simple structures like Vector3 or Quaternion), and set the transform with these values after your pause.

3.:

You can easily pause your animation with:

animator.enabled = false;

Finally:

Consider using Time.timeScale and Time.fixedDeltaTime for pausing of your game instead.