Save and load prefab error message.

Discussion and help for Easy Save 3
Gee85
Posts: 10
Joined: Sun Oct 01, 2017 9:34 pm

Save and load prefab error message.

Post by Gee85 »

I have some working code that saves and loads lists of gameobjects, their position rotation and materials.... if I don't use prefabs and don't close the game. (If I close the game it loads them but with no mesh)

The problem I'm having now however is, I followed the guide on setting up a prefab (right click prefab > ES3 > enable easysave for prefab). Then I drag an instance of it into the game world and save it. The save appears to go fine, however,
once I click the load button it throws this error:

MissingReferenceException: Prefab with ID 8285752017163807515 could not be found.
ES3Types.ES3Type_ES3PrefabInternal.Read[GameObject] (.ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/ES3Prefab.cs:130)
ES3Reader.ReadObject[GameObject] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader.Read[GameObject] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:245)
ES3Types.ES3Type_GameObject.Read[GameObject] (.ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:103)
ES3Reader.ReadObject[GameObject] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader.Read[GameObject] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:245)
ES3Reader.Read[GameObject] (System.String key) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:162)
ES3.Load[GameObject] (System.String key, .ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:256)
ES3.Load[GameObject] (System.String key, System.String filePath) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:235)
ES3_Load.Load () (at Assets/ES3_Load.cs:14)
UnityEngine.Events.InvokableCall.Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:154)
UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:637)
UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:773)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:52)
UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:36)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:45)
UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update()


However the prefab is there and the instance id is correct..
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save and load prefab error message.

Post by Joel »

Hi there,

Please could you create a very basic test project which replicates this and PM me a link to it? We don't appear to be having issues with prefabs at our end.

Many thanks,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Gee85
Posts: 10
Joined: Sun Oct 01, 2017 9:34 pm

Re: Save and load prefab error message.

Post by Gee85 »

Here is a screengrab of the test area I use for getting the basics right before implementing to a project =)

https://www.dropbox.com/s/j5kgx648ah1a2 ... w.PNG?dl=0

I'll paste the code snippets for you to scan over also:

Code: Select all

public void Save()
    {
        List<GameObject> bricks = new List<GameObject>(GameObject.FindGameObjectsWithTag("Player"));
        List<Vector3> brickPos = new List<Vector3>();
        List<Quaternion> brickRot = new List<Quaternion>();
        List<Material> brickMat = new List<Material>();

        if (bricks.Count == 0)
        {
            Debug.LogWarning("Error: No objects placed in bricks list. Check TAG on gameobject to ensure it has Player selected");
            return;
        }

        foreach (GameObject go in bricks)
        {
            brickPos.Add(go.transform.position);
            brickRot.Add(go.transform.rotation);
            brickMat.Add(go.GetComponent<MeshRenderer>().material);
        }

        for (int i = 0; i < bricks.Count; i++)
        {
            ES3.Save<GameObject>("go" + i.ToString(), bricks[i], "brickInfo.dat");
            ES3.Save<Vector3>("goPos" + i.ToString(), brickPos[i], "brickInfo.dat");
            ES3.Save<Quaternion>("goRot" + i.ToString(), brickRot[i], "brickInfo.dat");
            ES3.Save<Material>("goMat" + i.ToString(), brickMat[i], "brickInfo.dat");
        }

        ES3.Save<int>("count", bricks.Count, "brickInfo.dat");        
    }

Code: Select all

public void Load()
    {
        int count = ES3.Load<int>("count", "brickInfo.dat");
        List<GameObject> bricks = new List<GameObject>();

        for (int i = 0; i < count; i ++)
        {
            bricks.Add(ES3.Load<GameObject>("go" + i.ToString(), "brickInfo.dat"));    
            bricks[i].transform.position = ES3.Load<Vector3>("goPos" + i.ToString(), "brickInfo.dat");
            bricks[i].transform.rotation = ES3.Load<Quaternion>("goRot" + i.ToString(), "brickInfo.dat");
            bricks[i].GetComponent<MeshRenderer>().material = ES3.Load<Material>("goMat" + i.ToString(), "brickInfo.dat");
        }
    }
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save and load prefab error message.

Post by Joel »

Hi there,

I've managed to track down the issue and it will be fixed in the next update. If you require a fix in the meantime, please PM me your invoice number and I'll send you over a patch.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Gee85
Posts: 10
Joined: Sun Oct 01, 2017 9:34 pm

Re: Save and load prefab error message.

Post by Gee85 »

Excellent work! So it's not just me then? Thought I was going crazy haha. If the issue holds me back I will fire you my invoice number otherwise I can hang on =)

Thanks for the excellent product and support!
witylernn
Posts: 1
Joined: Mon Oct 02, 2017 11:58 pm

Re: Save and load prefab error message.

Post by witylernn »

I am having the same issue I would love to be sent the patch. PMing you my invoice number.
Gee85
Posts: 10
Joined: Sun Oct 01, 2017 9:34 pm

Re: Save and load prefab error message.

Post by Gee85 »

I have tried to PM you but the messages seem to hang in my outbox? Is there any other way I can send you the invoice number?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save and load prefab error message.

Post by Joel »

Gee85 wrote:I have tried to PM you but the messages seem to hang in my outbox? Is there any other way I can send you the invoice number?
The PM stays in the outbox until I've read it, but it appears you've deleted the message so I can no longer read it. If you send me another PM or contact me using the form at moodkie.com/contact with your invoice number, I'll send you the fix.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Gee85
Posts: 10
Joined: Sun Oct 01, 2017 9:34 pm

Re: Save and load prefab error message.

Post by Gee85 »

Thanks for the fix however I am now experiencing a new error.. So now I can load the prefab into the scene whilst the game is running and the original item is still there.
However it is duplicating the item (doesn't duplicate if it isn't a prefab like a primitive cube dropped in saved, deleted and loaded), not the main problem here though..

The main issue now is when I save the file with a gameobject (prefab save enabled)... then Either start a scene without the item there, or delete the gameobject and try to load it after saving... it loads the gameobject/prefab with the saved material at the saved location with the saved rotation.... but gives these error messages.... Even if I just save and load a prefab default cube with no transform or material data.

Can't add component 'MeshFilter' to Box because such a component is already added to the game object!
UnityEngine.GameObject:AddComponent(Type)
ES3Types.ES3ComponentType:GetOrAddComponent(GameObject, Type) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ComponentType.cs:100)
ES3Types.ES3ComponentType:ReadObject(ES3Reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ComponentType.cs:69)
ES3Types.ES3ObjectType:Read(ES3Reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:40)
ES3Types.ES3ObjectType:Read(ES3Reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:34)
ES3Reader:ReadObject(ES3Type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader:Read(ES3Type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:245)
ES3Types.ES3ArrayType:Read(ES3Reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ArrayType.cs:57)
ES3Reader:Read(ES3Type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:241)
ES3Reader:Read() (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:98)
ES3Types.ES3Type_GameObject:ReadInto(ES3Reader, Object) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:147)
ES3Types.ES3Type_GameObject:Read(ES3Reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:117)
ES3Reader:ReadObject(ES3Type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader:Read(ES3Type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:245)
ES3Types.ES3ListType:Read(ES3Reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ListType.cs:60)
ES3Reader:Read(ES3Type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:241)
ES3Reader:Read(String) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:162)
ES3:Load(String, ES3Settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:256)
ES3:Load(String, String) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:235)
ES3_Load:Load() (at Assets/ES3_Load.cs:29)
ES3_Save_Load_Event:Event_LoadMission() (at Assets/ES3_Save_Load_Event.cs:23)
UnityEngine.EventSystems.EventSystem:Update()

NullReferenceException: Object reference not set to an instance of an object
ES3Types.ES3Type_MeshFilter.ReadComponent[Object] (.ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/Component Types/ES3Type_MeshFilter.cs:32)
ES3Types.ES3ComponentType.ReadObject[Object] (.ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ComponentType.cs:92)
ES3Types.ES3ObjectType.Read[Object] (.ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:40)
ES3Types.ES3ObjectType.Read[Object] (.ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:34)
ES3Reader.ReadObject[Object] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader.Read[Object] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:245)
ES3Types.ES3ArrayType.Read (.ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ArrayType.cs:57)
ES3Reader.Read[Component[]] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:241)
ES3Reader.Read[Component[]] () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:98)
ES3Types.ES3Type_GameObject.ReadInto[Object] (.ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:147)
ES3Types.ES3Type_GameObject.Read[Object] (.ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:117)
ES3Reader.ReadObject[Object] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:215)
ES3Reader.Read[Object] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:245)
ES3Types.ES3ListType.Read (.ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ListType.cs:60)
ES3Reader.Read[List`1] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:241)
ES3Reader.Read[List`1] (System.String key) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:162)
ES3.Load[List`1] (System.String key, .ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:256)
ES3.Load[List`1] (System.String key, System.String filePath) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:235)
ES3_Load.Load () (at Assets/ES3_Load.cs:29)
ES3_Save_Load_Event.Event_LoadMission () (at Assets/ES3_Save_Load_Event.cs:23)
UnityEngine.Events.InvokableCall.Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:154)
UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:637)
UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:773)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:52)
UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:36)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:45)
UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update()
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save and load prefab error message.

Post by Joel »

Hi there,

Would you be able to PM me a basic test project which replicates this? I don't appear to be getting this issue when using the previous code you sent me.

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