Loading vs Instantiating Questions

Discussion and help for Easy Save 3
Post Reply
Larry2013z
Posts: 8
Joined: Sun Mar 21, 2021 7:42 pm

Loading vs Instantiating Questions

Post by Larry2013z »

Hi Joel,

I have some questions about Loading vs Instantiating. I am using Unity 2020.3.5 LTS.

1) I’ve noticed that the Start() function will NOT run when an object is loaded but it WILL run when it is instantiated – Why is this and what is the recommended workaround if I need Start() to run when an object is loaded?

2) If I make a prefab particle system and then instantiate the prefab it works without error messages. If I Save and the Load the same prefab I will get the following error messages:
• Setting the duration while system is still playing is not supported. Please wait until the system has stopped and all particles have expired or call Stop with ParticleSystemStopBehavior.StopEmittingAndClear to completely stop the system.
UnityEngine.ParticleSystem/MainModule:set_duration (single)

• Setting the random seed while system is still playing is not supported. Please wait until the system has stopped and all particles have expired or call Stop with ParticleSystemStopBehavior.StopEmittingAndClear to completely stop the system.
What is the best way to solve this problem?

3) Besides those two specific questions – what is best way to think about loading vs instantiating? Is there anything else I need to look out for?

Thanks,
Larry
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading vs Instantiating Questions

Post by Joel »

Hi Larry,

Easy Save won't affect the Start() function of any objects in your scene, as this is fully controlled by Unity. Please could you replicate this in a new project and private message it to me?

Regarding the particle system, this is because the particle system is running when you attempt to load. In the next update we'll be stopping the particle system for you before loading. If you private message me your invoice number I can send over this update.

Otherwise, I can't think of anything else you need to look out for.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
tab.tang
Posts: 1
Joined: Wed Jun 02, 2021 12:56 am

Re: Loading vs Instantiating Questions

Post by tab.tang »

Sorry for my bad English.

So how do you solve the situation when you use easy save3 to load a prefab with particle system.
I find that if we ignore the error, the program which controls the particle system can still work.

And I have aother question about the sequence of loading the prefabs which have reference to other prefab.
Normally, wo should first load the prefab being referenced.And if we reverse the order, there may be some error in the prefab being referenced.

So it is a problem to solve circular reference. My solution is to try to keep the above item in mind, and then if there are some reference is null, we should assign it when load the prefab.

Do you have a better solution?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading vs Instantiating Questions

Post by Joel »

Hi there,
So how do you solve the situation when you use easy save3 to load a prefab with particle system.
I find that if we ignore the error, the program which controls the particle system can still work.
If the particle system is part of a prefab and you don't need it to be saved or loaded, you can simply tell Easy Save to not serialise the particle system by creating an ES3Type for it in Tools > Easy Save 3 > Types with no fields selected.
So it is a problem to solve circular reference. My solution is to try to keep the above item in mind, and then if there are some reference is null, we should assign it when load the prefab.

Do you have a better solution?
That is indeed the correct way to go, as you can't load a reference to a prefab which doesn't exist. Alternatively you can load twice: once to ensure the instances are created, and again to load the references.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply