Hey all, I want to implement a save and resume feature for my TD game. I have a grid and enemies walks on free tiles which are walkable. I have researched about game saving in unity and found “PlayerPrefs”, but this function doesn’t saves the complete gameobjects and some other class variables. If ill use this function I have to store all enemies positions/rotations, tile numbers, tower numbers/position and so many stuff separately . Would there is any other better solution to save complete gameobjects or any other way to make life easier ??
While there is many ways to save data, such as PlayerPrefs, external database, simple text file, etc… There is no way to save a world state. The closest you can get is serialization (either binary or XML), which can traduct whole scripts/objects into a byte array, or a long string. That requires the class definition to be marked as System.Serializable. The Transform class, along others, isn’t Serializable, hence any objects related to GameObject or Transform cannot be serialized.
Using serialization, you must deconstruct/reconstruct the world state yourself using custom logic.