Page 1 of 1

SpawnedObject(Dialogue System)

Posted: Mon Mar 11, 2024 12:40 pm
by MakeCodeNotWar
Hi

I can't figure out how to save/load a spawned object's state.
For some reason the parameter of ApplyData is always empty (the object spawns on it's last position).

Thank you for help.

Code: Select all

    public class SpawnedItem : PixelCrushers.Wrappers.SpawnedObject {
        public override string RecordData() {
        	   //setting saveData json string
                   retrun saveData;
        }
        
        public override void ApplyData(string data) {
           Debug.Log($"ApplyData: {data}"); // the data is always empty
        }
    }

Re: SpawnedObject(Dialogue System)

Posted: Mon Mar 11, 2024 3:17 pm
by Tony Li
Hi,

What state do you want to save or load? In general, if you want to save some other state on a spawned object, leave the SpawnedObject component alone and add a separate Saver component. For example, if a spawned object has a child GameObject can be active or inactive, you can add an ActiveSaver to the spawned object and assign the child to its Target field. Then tick the SpawnedObjectManager's "Apply Save Data To Spawned Objects On Restore" checkbox, and set the SaveSystem component's "Frames To Wait Before Apply Data" to 1 or higher. (If Frames To Wait Before Apply Data must be zero in your setup, use the upcoming DS version 2.2.44.)