Hello GiL,
I'm curious if this is possible with ORK or Makinom at the moment. Let's say I would get a 3rd party asset from Unity store that would pick up object and during runtime I can rotate it and place it in the world, e.g. like Sims...
How would I be able to save this thing in a save game? ORK doesn't care about spawned prefabs.
I've got something like this available here. In short, it's a custom save data that has to be registered at game start and uses nodes to add/remove prefabs (i.e. spawned via events), which will automatically be spawned when loading scenes. Via some custom scripting you should also be able to add the spawned prefabs from code.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
1. Put your 'PrefabCustomSaveData' script in my Main Menu scene where ORK Game Starter is located (however my project starts 1 scene before with Makinom).
2. Put the specific prefab there and named it ORKbarrel.
3. Added this script into the prefab as well just in case.
4. Spawned that prefab in a scene in Editor Runtime. Saved it via ORK Save Menu and re-loaded via ORK Load Menu, prefab was there, but when I turned off Unity Editor and started the project, loaded my save, it was missing.
What am I doing wrong?
Also, the prefabs have to be spawned using the event system and added to the data via Add Prefab Save nodes. Or, you can do it via script using the component's Add function.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
1. I need to have separate empty game object for each PrefabCustomSaveData script...if I put multiple scripts with prefabs under same game object, the AddPrefabSave doesn't recognize it and uses the first script always, therefore, spawning first set prefab.
2. That means important question: Will e.g. having 50 empty objects set on Don't Destroy On Load with different prefabs have impact on performance?
3. When I spawn the prefab from script, that calls Global Event that also Spawns Prefab, the Add Prefab Save or the script itself doesn't work, object won't be saved, so only directly spawning in one event works.
4. When the object is finally saved though, It's instance isn't deleted upon loading different save slot during runtime.
E.g. I have 3 save game slots. The saved prefab is in Save Slot 1, I load it, then load Save Slot 2 with different data, the prefab is spawned there too. Have to Exit Game to Main Menu and the load a save for it to disappear.
5. As mentioned in point 3., in this case it'll probably be better to save the prefab via script using your mentioned component Add function. Could you please elaborate, how to write it there?
gameObject.AddComponent( type ); is what I've found but got no idea, game object name is 'BarrelSave', the component should be 'PrefabCustomSaveData', right?
Thing is, my custom spawn prefab script uses prefab array set by Integers, so got no idea how to e.g. set 'BarrelSave' game object for Integer 0, 'ForgeBlowerSave' game object for Integer 1 and so on.
2) Not much, they just exist and don't do much to impact performance.
3) When spawning via script, use the component's Add function to add the prefab instance instead of going via events. Since you're using different prefabs, you first have to find the one matching for this prefab, though.
4) Hm, is it actually reloading the scene in that case?
5) If your custom spawn prefab script is set up in the same scene, you could just add the references to the save components and access it like that.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
This action is overly complicated and requires a skilled programmer.
4. Yes, it was reloading the scene, since you can't really clear it in any simple way, it's pretty much forcing user to go to Main Menu no matter what.
5. Same like step 3. Extremely complicated for non coder to add a simple building+saving prefab feature. Unless you go full ORK solution. Though ORK can't mount objects on mouse cursor, so you'll end up in-between no-go situations.
I'd need more information on how you want it to work, e.g. I'm not really sure if the prefabs you want to save are spawned via your custom script or via the event system.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Asset I'm using spawns it's own prefabs. Problem is, that the 'PrefabCustomSaveData' script works only with ORK spawned objects.
Is there a way, I can pass the prefab with it's components and child objects to that script without using the 'Spawn Prefab' node, please?
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Can you please explain, how do I define on which save slot is being pressed by the player? I can't seem to check for Save Slots, only Autosave slots from nodes.
E.g. If player press Save Slot 1, our custom script passes all object data to Save Slot Index 1.
To add to what he said, we are saving extra information to a separate external file. Which file to save to or load from depends on the save slot the player chose.
Now we can implement `ISaveData` to process the save/load event but we haven't been able to determine the save slot. Also, we're using the generated save menu UI. We were hoping there would be a way to easily get the information.
Would appreciate any advice here.
There's no need to separately save this data, if that's what you're asking about.
If you need to know which was the last save slot used by the player (saving or loading), you can access that via:
ORK.SaveGame.LastIndex
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!