Saving a Gameobject thats being added in playmode

Discussion and help for Easy Save 3

Saving a Gameobject thats being added in playmode

Postby Roydem » Wed Jul 10, 2019 1:10 pm

Is there a possibility that i can load an object that gets destroyed after play mode?
For Example : lets say whenever a player presses left click it summons a box on hit location, can i then exit the game, open it and then the save asset will summon the box in the same place with the same attributes?
Roydem
 
Posts: 2
Joined: Wed Jul 10, 2019 1:06 pm

Re: Saving a Gameobject thats being added in playmode

Postby Joel » Wed Jul 10, 2019 5:40 pm

Hi there,

This is covered in the Saving and Loading Prefab Instances section here:
https://docs.moodkie.com/easy-save-3/es ... s-prefabs/

There's also an example of doing this without ES3Prefab components here:
https://moodkie.com/forum/viewtopic.php?f=16&t=1438

All the best,
Joel
Joel Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2336
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving a Gameobject thats being added in playmode

Postby Roydem » Thu Jul 11, 2019 6:11 am

Thank you for commenting so fast, can i use auto save on it because it says it doesn’t find the prefab. The prefab contains the easysave prefab component and the auto save component, both are es3.
Do i have to do it with scripting on my own ? Or can i make use of auto save, and if yes how do i do it properly?

Thank you so much for the great help,
Roy
Roydem
 
Posts: 2
Joined: Wed Jul 10, 2019 1:06 pm

Re: Saving a Gameobject thats being added in playmode

Postby Joel » Thu Jul 11, 2019 4:41 pm

Hi there,

You can use it with Auto Save. You will need to make sure that there is a reference to your prefab in your scene, otherwise it will not be added to the Easy Save manager.

The easiest way to do this would be to add this script to your scene, and then drag your prefab into the objects array of this script.

using UnityEngine;

public class IncludeInScene : MonoBehaviour
{
public UnityEngine.Object[] objects;
}


All the best,
Joel
Joel Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2336
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving a Gameobject thats being added in playmode

Postby ArtPose » Sun Jul 14, 2019 4:47 am

I am trying to do this same thing with Playmaker and your object prefab saving script attached. I am loading prefabs at runtime while the application is running. I added your script to the scene also that you suggested above. I am getting a error when i try and load objects that are created outside of unity. It works fine for spheres, cubes, cylinders and cones. These are all built into the player. They load and save just fine. The second i try to load and save a object created from outside the application. The prefab will not load and gives me a error saying it could not find the referenced object and gives the exact number of the object in the assets folder. I added all the objects to multiple arrays and still no luck. If i have the object in the scene already visible and move it. I can get it to load that object to the saved location. All the primitive objects work perfectly. This is a real issue for me because i am trying to save objects that a user would place in a scene to external files they can then load up later into my app. I am not sure where to put these items so load file can locate them. It seems to be able to find the built in objects just fine just not externally created ones. I tried your script above and it doesn't seem to work. I am using the latest version of your plugin and unity 2018.3.5. I am hoping you can give me some idea what could be causing this or some place to store the objects so your plugin can find them on load. Each object does have the prefab script attached.

thank you in advance
Artware studio
shawn ogle
ArtPose
 
Posts: 8
Joined: Wed Dec 24, 2014 6:33 am

Re: Saving a Gameobject thats being added in playmode

Postby Joel » Mon Jul 15, 2019 6:26 pm

Hi Shawn,

Please could you clarify what you mean by 'objects created outside of Unity'? Do you mean objects created outside of Playmode (i.e. Prefabs).

Please could you send me screenshots of your FSM and the GameObjects you're saving and loading?

All the best,
Joel
Joel Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2336
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving a Gameobject thats being added in playmode

Postby ArtPose » Tue Jul 16, 2019 6:58 pm

object trying to load.jpg
object trying to load.jpg (64.38 KiB) Viewed 30 times
A .obj file created in modo. They have the same scripts on them. The only difference is some (sphere, box) are internal created objects and the others are created in modo. This is the error message i am getting.
error-message-on-load.jpg
error-message-on-load.jpg (142.96 KiB) Viewed 30 times


this is the fsm I have set up. This works perfectly for spheres and cubes and for objects already in the scene just not ones that have to be loaded. I do have your array script also in the scene.
fsm-in-use.jpg
fsm-in-use.jpg (39.06 KiB) Viewed 30 times


I hope that helps as I really need this functionality to work. Let me know if you need anything else.

thanks in advance.
shawn ogle
ArtPose
 
Posts: 8
Joined: Wed Dec 24, 2014 6:33 am

Re: Saving a Gameobject thats being added in playmode

Postby Joel » Wed Jul 17, 2019 7:25 am

Hi Shawn,

I still don't appear to be able to replicate this at my end.

Please could you create a new project which replicates the issue with the minimal amount of content and PM it to me with instructions?

Just to clarify, does the object exist as a prefab outside of the scene (i.e. in the Assets folder)?

All the best,
Joel
Joel Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Joel
Moodkie Staff
 
Posts: 2336
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving a Gameobject thats being added in playmode

Postby ArtPose » Wed Jul 17, 2019 3:26 pm

all objects are in the same folder in the assets folder. I will make a new project and try again.

thank you for the help.
ArtPose
 
Posts: 8
Joined: Wed Dec 24, 2014 6:33 am


Return to General Discussion

Who is online

Users browsing this forum: Bing [Bot] and 5 guests