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.
  • This can be done via custom save data or custom component save data, though custom save data is probably better for this.

    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited March 2021
    Alright, not a coder, so, let me just wrap it in more simple way :)

    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?
    Post edited by Machal on
  • Remove the script from the prefab, that'd basically lead to a new custom save data being registered with the save system whenever a prefab is spawned, replacing the previous one.

    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited March 2021
    Ok, got it to work, however, after 2 hours of testing, found few issues with it:

    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.
    Post edited by Machal on
  • 1) Having multiple components on the same game object should work, just make sure they all have a different register name, or they will override each other in the save system.

    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited March 2021
    3. It's not that simple, using Global Events is for spawning different other things, such as particles, currency control and other stuff so it's necessary to be part of it.
    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.
    Post edited by Machal on
  • Well, yeah - this is a custom solution, so it'll require some programming to make it work the way you want. As-is, this is able to save prefabs that are spawned via the event system if set up and used correctly.

    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I'm working with a friend on how to fix this thing.

    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?
  • gamingislove said: 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.
    :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Ok, now the problem is saving it to the right file. I'm using NO autosaves. Just classic save menu with 3 save slots to choose from.

    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.
  • edited April 2021
    Hello GiL. I'm the coder friend Machal mentioned.

    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.
    Post edited by Vanlalhriata on
  • edited April 2021
    The ISaveData implementation will register to ORK's save system and save with whatever save slot the player (or the system) saves to. The whole custom save data (also custom component save data) is integrated with ORK's save system and doesn't require any additional thing (only registering, as e.g. it's done in the example).
    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
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks GiL, much appreciated! :)
Sign In or Register to comment.