Help with loading prefabs!

Discussion and help for Easy Save 3
Junglerally
Posts: 12
Joined: Wed Jan 12, 2022 12:11 am

Help with loading prefabs!

Post by Junglerally »

I have a game where you build mini-golf holes. I am using an asset called spline mesh to make the holes. https://assetstore.unity.com/packages/t ... esh-104989 I put the link to the asset store page somewhere in here. So I have a prefab called new hole that is a basic hole that spawns when you want to build a new hole. I enabled EasySave3 for the prefab. When I have the loading time set to "Awake", it gives me this error:

Code: Select all

MissingReferenceException: Prefab with ID 7166338961800394986 could not be found.
Press the 'Refresh References' button on the ES3ReferenceMgr Component of the Easy Save 3 Manager in the scene to refresh prefabs.
I have refreshed it at every time that I could think of and nothing works. When I set the loading time to "Start" I get some NullReferenceExceptions related to SplineMesh. I have no clue how to fix either one of these issues, so if anyone has any ideas please let me know. I am very new to this asset (bought it yesterday). Thanks in advance!
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Help with loading prefabs!

Post by Joel »

Hi there,

As we don’t officially support the asset you speak of and I have no experience with it I’m afraid I can’t comment directly on that.

However, the warning you’re getting means that the data you’re loading has a field which is stored by reference (I.e. it’s a UnityEngine.Object type), but the object it’s trying to load a reference to no longer exists.

In these cases you would need to ensure that you also save the object being referenced, and load it before loading the object which references it.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Junglerally
Posts: 12
Joined: Wed Jan 12, 2022 12:11 am

Re: Help with loading prefabs!

Post by Junglerally »

So all of the holes are under 1 parent game object, but when I put a save function on that and chose "save children", it still gives me the error. So how would I go about doing that? I am just using autosave for my scene. But the hole prefab has a bunch of SplineMesh stuff on it, which I know you said you don't support, and then the prefab will have a lot of children because it will also store the special buildings you put on it, and the mesh of the hole generated by SplineMesh (under three parents (NewHole > Mesh > gernatedbySplineMesh)). I am not sure which one is causing this, but I know the NullReferenceExceptions are coming from the third object in that hierarchy, which is generated at runtime (the other two are in the prefab). So if you have any ideas or need any more information let me know. Thanks!
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Help with loading prefabs!

Post by Joel »

Hi there,

You shouldn't manually add an Auto Save component or modify it's variables. You should only interact with Auto Save through the Auto Save window. In your case you specifically need the Prefabs section of the Auto Save window.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Junglerally
Posts: 12
Joined: Wed Jan 12, 2022 12:11 am

Re: Help with loading prefabs!

Post by Junglerally »

I got rid of all the auto-save stuff on the parent. I also saw these objects being spawned instead of the other things I want to save.
objs.png
objs.png (8.88 KiB) Viewed 1575 times
I am assuming that means I have to write something manually, it's telling me that I need to use LoadInto(). What should I do? These objects have the scripts on them with the saved data, but I want them to be loaded into the normal gameobjects with the scripts.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Help with loading prefabs!

Post by Joel »

Hi there,

This means that the GameObject you’re loading doesn’t exist anymore, so it’s creating a new GameObject to load the data into.

If you don’t want it to create a new instance and have your own instance to load into, you can indeed use ES3.LoadInto to load the data into an existing instance.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Junglerally
Posts: 12
Joined: Wed Jan 12, 2022 12:11 am

Re: Help with loading prefabs!

Post by Junglerally »

I figured out that if I change the load time in the settings to start that it all works, but I get some errors with spline mesh. I am thinking about creating a coroutine for loading that will load everything. But one question, is there a bool that will tell me when the game is done loading?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Help with loading prefabs!

Post by Joel »

Hi there,

Loading happens synchronously, so there is no need for a ‘done’ flag.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Junglerally
Posts: 12
Joined: Wed Jan 12, 2022 12:11 am

Re: Help with loading prefabs!

Post by Junglerally »

I am still having so much trouble, most of which is with that spline mesh asset. It is still giving me NullReferenceExceptions, or when I tried a new approach nothing ever whos up. Also, I don't think the asset is actually saving the spline, even though I have it set to save the spline script. I am about ready to give up. This is my first commercial project and I wanted it to go well, but if I can't get saving to work I don't know what I am gonna do. Giving up would mean a lot of unhappy people because I have already made a community around the game. I do thank you for all your help, and I know that you don't support SplineMesh or anything, but I appreciate your trying to assist me.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Help with loading prefabs!

Post by Joel »

Hi there,

Please could you show me how you've set it to save the Spline script, and the contents of the Spline script itself?

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