Disable Saving on Prefab instance?

Discussion and help for Easy Save 3
Post Reply
Maple-Senpai
Posts: 7
Joined: Tue Mar 22, 2022 9:17 am

Disable Saving on Prefab instance?

Post 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.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Disable Saving on Prefab instance?

Post by Joel »

Hi there,

How are you saving and loading your data?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Maple-Senpai
Posts: 7
Joined: Tue Mar 22, 2022 9:17 am

Re: Disable Saving on Prefab instance?

Post 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.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Disable Saving on Prefab instance?

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Maple-Senpai
Posts: 7
Joined: Tue Mar 22, 2022 9:17 am

Re: Disable Saving on Prefab instance?

Post 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.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Disable Saving on Prefab instance?

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Maple-Senpai
Posts: 7
Joined: Tue Mar 22, 2022 9:17 am

Re: Disable Saving on Prefab instance?

Post 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
Post Reply