How to save gameObject?

So its been a while ago that am looking for an answer for this question that how can I save a gameObject, Basically am so new to unity and one thing important that i don’t know about is saving data, I already tried PlayerPrefs to saving the coins, other strings and things that can do with PlayerPrefs, and now I want to save GameObject but it cannot in PlayerPrefs, So About saving GameObject I want when a user buys a skin and then closes the application, the skin saves and load when the user back to the game or buliding an Object in the scene want to save, is there any easy way to do that…?

there are several ways to do what you want…

Method N1: PlayerPrefs!

Just save a small string that contains the skin you’re into, and then load the 3D file or Sprite into the player object.

Method N2: PlayerPrefs + Prefabs!

Same as the method above but load the player prefs on a level manager and load a Prefab object (if you don’t know what’s a prefab then google it up, is like a copy of an object) then load the prefab from Resources and instantiate it (google load assets from Resources)

this might be a litle tricky if you’re new into Unity but is a really good method. Also don’t forget that player prefs were created to save… player prefs… if you have to load or save data, you should use a Json File (again google how to save data with Json)

Method N3: Ugly but effective!

A litle bit like the one before but from a manager (like level manager or game manager)

just save a lot of prefabs of the player, one for each skin, and then add references to the manager (to avoid loading from resources) and instantiate the prefab according to the player’s current skin…

My Method would be:

1 Save player data inside a Json File

2 Load Player data From a Manager

3 Load the correct prefab from Resources

4 Instatiate the correct Prefab

hope this helps!

using UnityEngine;

public class Example : MonoBehaviour
    public void SetInt(string KeyName, int Value)
        PlayerPrefs.SetInt(KeyName, Value);

    public int Getint(string KeyName)
        return PlayerPrefs.GetInt(KeyName);