Download and save obj file.

Discussion and help for Easy Save 3
Post Reply
kaizzen
Posts: 5
Joined: Wed May 09, 2018 6:54 pm

Download and save obj file.

Post by kaizzen »

I want download from server a xxx.obj file or xxxxx.fbx and save it in runtime. I can download with WWW api from the server and with other scripts I can transform in gameobject. My question. Can I save a gameobject with Easy save? or can I download obj file and save it? Thanks for the answer.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Download and save obj file.

Post by Joel »

Hi there,

To save the obj file to local storage, you can use ES3.SaveRaw(www.bytes, "myfile.obj"); to store the data downloaded from your WWW request.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
kaizzen
Posts: 5
Joined: Wed May 09, 2018 6:54 pm

Re: Download and save obj file.

Post by kaizzen »

Thanks for your answer. If you can help me a bit...
I save the object with GameObject piramide = ES3.LoadRawBytes ("piramide.obj");
to load I use ES3.SaveRaw(http://www.bytes, "piramide.obj"); and this return a byte[].
My question. How can I transform byte[] to gameobject or obj file?
kaizzen
Posts: 5
Joined: Wed May 09, 2018 6:54 pm

Re: Download and save obj file.

Post by kaizzen »

Ok I save with ES3.Save<GameObject>("myGameObject", importedObject); and load with Instantiate (ES3.Load<GameObject>("myGameObject")); But it give me an object without mesh. ¿Do yo know why? I must change some parameter....
Thanks for the answer.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Download and save obj file.

Post by Joel »

Hi there,

The Mesh is a reference type, so it will be stored by reference. If there is no reference at runtime, it won't have anything to load.

Instead you should save the Mesh separately. i.e.
ES3.Save<Mesh>("myMesh", this.GetComponent<MeshFilter>.sharedMesh);
this.GetComponent<MeshFilter>.sharedMesh = ES3.Load<Mesh>("myMesh");
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
kaizzen
Posts: 5
Joined: Wed May 09, 2018 6:54 pm

Re: Download and save obj file.

Post by kaizzen »

Sorry only one question more and thanks to your answers:
ES3.Save<GameObject>("myGameObject", importedObject);
ES3.Save<Mesh>("myMesh", importedObject.GetComponent<MeshFilter>.sharedMesh);
Destroy (importedObject);

loadObject = ES3.Load<GameObject>("myGameObject");
importedObject.GetComponent<MeshFilter>.sharedMesh = ES3.Load<Mesh>("myMesh");
loadObject.AddComponent<Move> ();
Unity no recognize sharedmesh. what can i write to in this context to save the mesh?
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Download and save obj file.

Post by Joel »

Hi there,

I'm not sure why sharedMesh is not being recognised by Unity, as it's very clearly in their API: https://docs.unity3d.com/ScriptReferenc ... ilter.html

You may need to contact them regarding this, as it appears to be working fine at my end.

You can try to simply use mesh instead of sharedMesh, but presumably this won't be recognised either.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
kaizzen
Posts: 5
Joined: Wed May 09, 2018 6:54 pm

Re: Download and save obj file.

Post by kaizzen »

Not run because the object is in a runtime enviroment there aren't a instance. I think is it, but I don't know how change. Thanks for all.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Download and save obj file.

Post by Joel »

Hi there,

I'm not sure I understand what you mean. Would you be able to demonstrate in more detail?

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