Page 1 of 1

Disable Saving on Prefab instance?

Posted: Sat May 07, 2022 11:37 am
by Maple-Senpai
Hi,

So I have ES3 enabled on a prefab it saves fine. But I instantiate two of these prefab. One will be the original and the other will be the copy. I want to disable saving on the copy and only save the original. I tried removing ES3Prefab component on the copy but it still gets saved.

Re: Disable Saving on Prefab instance?

Posted: Sat May 07, 2022 11:54 am
by Joel
Hi there,

How are you saving and loading your data?

All the best,
Joel

Re: Disable Saving on Prefab instance?

Posted: Sat May 07, 2022 12:02 pm
by Maple-Senpai
Joel wrote: Sat May 07, 2022 11:54 am Hi there,

How are you saving and loading your data?

All the best,
Joel
I save on OnApplicationExit and I load on scene start.

Re: Disable Saving on Prefab instance?

Posted: Sat May 07, 2022 12:06 pm
by Joel
Sorry, I was unclear with my question :) Are you using code, or Auto Save, or Visual Scripting (PlayMaker, Bolt, Unity VS)?

If you're using code, please could you post the code you're using to save and load?

All the best,
Joel

Re: Disable Saving on Prefab instance?

Posted: Sun May 08, 2022 3:30 am
by Maple-Senpai
Joel wrote: Sat May 07, 2022 12:06 pm Sorry, I was unclear with my question :) Are you using code, or Auto Save, or Visual Scripting (PlayMaker, Bolt, Unity VS)?

If you're using code, please could you post the code you're using to save and load?

All the best,
Joel
Hi,

I'm using code.

SavingManager.cs

Code: Select all

    private void SavePotioneers() 
    {
        GameObject[] potioneers = GameObject.FindGameObjectsWithTag("Potioneers");
        ES3.Save(_potioneersKey, potioneers);
    }
    
    private void OnApplicationQuit()
    {
    	SavePotioneers();
    }
LoadingManager.cs

Code: Select all

	private void Start()
	{
		LoadPotioneers();
	}
	
	private void LoadPotioneers()
    	{
            if (ES3.KeyExists(_potioneersKey))
            {
                ES3.Load(_potioneersKey);
   	    }
   	}
EDIT:

Instantiang the original and copy of the prefab:

Code: Select all

	private void CreateCopyAndOriginal()
	{
		GameObject orignal = Instantiate(GameManager.Instance.NPCManager.PotioneerList[i].potioneer);
	        GameObject instantiateCopy = Instantiate(GameManager.Instance.NPCManager.PotioneerList[i].potioneer);
        	Destroy(instantiateCopy.GetComponent<ES3Prefab>());
	}
Then when I exit the game the instantiatedCopy still gets saved even if i destroyed the ES3Prefab component.

Re: Disable Saving on Prefab instance?

Posted: Sun May 08, 2022 9:49 am
by Joel
Hi there,

The GameObject is being saved because it's in the array that you're telling Easy Save to save. If you don't want to save that GameObject you should remove it from the array you're saving.

All the best,
Joel

Re: Disable Saving on Prefab instance?

Posted: Sun May 08, 2022 10:24 am
by Maple-Senpai
Joel wrote: Sun May 08, 2022 9:49 am Hi there,

The GameObject is being saved because it's in the array that you're telling Easy Save to save. If you don't want to save that GameObject you should remove it from the array you're saving.

All the best,
Joel
Thank you! You are a life saver. I did not notice that xD