SpawnedObject(Dialogue System)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
MakeCodeNotWar
Posts: 1
Joined: Mon Mar 11, 2024 12:18 pm

SpawnedObject(Dialogue System)

Post 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
        }
    }
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: SpawnedObject(Dialogue System)

Post 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.)
Post Reply