Hi, I’m working in a mmorpg and I have a question:
I’ve created a scene where you can custom your character, activating/desactivating character’s children(such as hair, cloth, etc) you can custom it. The thing is that I want to save the character once it’s as you like and show it in the player’s profile as animated character.
I don’t know the command to do it, or if it’s possible to save activated/desactivated game objects inside oneother game object.
It’s probably best to save the choices as variable values; Once the player has selected the ones they want, pass the references to those objects to some controller object and have it hold on to the values. Any other object that needs them can then ask your controller which parts to use.
public GameObject Corto;
private string activado;
private string desactivado;
void OnGUI () {
if (GUI.Button(new Rect(1220, 640, 70, 30), “Cear”))
{
if (Corto.activeSelf == true)
{
PlayerPrefs.SetString(“Pelo1”, activado);
}
if (Corto.activeSelf == false)
{
PlayerPrefs.SetString(“Pelo1”, desactivado);
}
SCRIPT TO GET WHAT I SAVED:
void Start()
{
PlayerPrefs.GetString(“Pelo1”);
if (string.Contains(activado))
{
Corto.SetActive(true);
}
}
But there is an error: it says that ‘’ if (string.Contains(activado)) ‘’ is wrong (An object refence is required). So how can I say ‘’ if the saved string with the key ‘‘Pelo1’’ is ‘‘Activado’’, then activate the gameobject called Corto’'?