DataSection.Save
Declaration#
public virtual void Save(string filename, Action onComplete)Parameters#
| Name | Description |
|---|---|
| filename | Full path of file to save |
| onComplete | Action to invoke when save is complete |
Description#
Saves data to a file
Usage#
Example
using NullSave.GDTK;using System.IO;using UnityEngine;
public class CodeSample : MonoBehaviour{
public void ExampleMethod() { // You can create your own DataSections to work with DataSection target = new DataSection();
// Values in a custom DataFile are never saved/loaded by the system // They can be saved/loaded manually target.SetVector3("vector3", new Vector3(1.2f, 3.4f, 5.6f)); target.SetString("string", gameObject.name);
// Data can be saved directly to a file // You can invoke an action when save is complete target.Save(Path.Combine(Application.persistentDataPath, "demoSection.sav"), SectionSaved); }
private void SectionSaved() { Debug.Log("SaveSystem: DataSection saved"); }
}Declaration#
public virtual void Save(Stream stream, Action onComplete)Parameters#
| Name | Description |
|---|---|
| stream | Stream to save |
| onComplete | Action to invoke when save is complete |
Description#
Saves data to a file
Usage#
Example
using NullSave.GDTK;using System.IO;using UnityEngine;
public class CodeSample : MonoBehaviour{
public void ExampleMethod() { // You can create your own DataSections to work with DataSection target = new DataSection();
// Values in a custom DataFile are never saved/loaded by the system // They can be saved/loaded manually target.SetVector3("vector3", new Vector3(1.2f, 3.4f, 5.6f)); target.SetString("string", gameObject.name);
// Data can be saved directly to a stream // You can invoke an action when save is complete using (MemoryStream ms = new MemoryStream()) { target.Save(ms, SectionSaved); } }
private void SectionSaved() { Debug.Log("SaveSystem: DataSection saved"); }
}