Show / Hide Table of Contents

Class XmlSaveableComponent

All components that you wish to be saved and loaded in some way between runtimes should inherit from XmlSaveableComponent in order to provide functionality for object persistance/reconstruction.

If you want to use the Awake and OnDestroy methods in XmlSaveableComponents, please use the override keyword and call base.Awake(); and/or base.OnDestroy();.

All XmlSaveableComponents have the [ExecuteInEditMode] attribute; therefore if you encounter unwanted behaviour due to MonoBehaviour methods being called at edit time, consider adding: if (!Application.isPlaying) return;

Inheritance
System.Object
SaveableComponent
XmlSaveableComponent
XmlSaveableComponentExample
Namespace: GlitchedPolygons.SavegameFramework.Xml
Assembly: UnityScriptsLibrary.dll
Syntax
public abstract class XmlSaveableComponent : SaveableComponent

Properties

| Improve this Doc View Source

ID

The XmlSaveableComponent's ID. This is a unique identifier that should be immutable and persistent.

Declaration
public override int ID { get; }
Property Value
Type Description
System.Int32
Overrides
SaveableComponent.ID

Methods

| Improve this Doc View Source

AfterLoading()

This is called after a successful Load(String).

Child classes should implement this and define what happens after the Load(String) fed the stored data into this class (e.g. if a SaveableComponent's Transform.position is stored in the savegame, this would be the place to then take that value and load it back into the Transform).

Declaration
public abstract override void AfterLoading()
Overrides
SaveableComponent.AfterLoading()
| Improve this Doc View Source

Awake()

Declaration
protected virtual void Awake()
| Improve this Doc View Source

BeforeSaving()

This is called by the SavegameManager implementation before saving this instance's data out to the savegame.

Use this to sync up any data if you need (e.g. loading Unity component data - which is NOT serialized alongside automatically; keep that in mind! - into some field on the savegame like for example a "Vector3 positionCoordinates;" or something like that, yea..)

Declaration
public abstract override void BeforeSaving()
Overrides
SaveableComponent.BeforeSaving()
| Improve this Doc View Source

GetXml()

Gets the nicely formatted xml System.Xml.Linq.XElement containing all the data that is needed to reconstruct the saveable object through LoadXml(XElement).

Declaration
public abstract XElement GetXml()
Returns
Type Description
System.Xml.Linq.XElement

The System.Xml.Linq.XElement containing all data needed to reconstruct the object on LoadXml(XElement).

| Improve this Doc View Source

LoadXml(XElement)

Loads an System.Xml.Linq.XElement (hopefully the one that was originally produced by the GetXml() method) into the class.

This method should reconstruct the object's state on load, and then return true if the procedure was successful (false if it failed in some way).

Declaration
public abstract bool LoadXml(XElement xml)
Parameters
Type Name Description
System.Xml.Linq.XElement xml

The System.Xml.Linq.XElement that was obtained via GetXml().

Returns
Type Description
System.Boolean

Should return true if the loading procedure was successful; false if it failed in some way.

Remarks

This should NOT be used to make the SaveableComponent use the loaded data in any way: THIS IS JUST FOR LOADING DATA INTO THE CLASS FIELDS! Instead, use the AfterLoading() method for applying the loaded data (e.g. setting Transform positions and rotations and whatnot)!

| Improve this Doc View Source

OnDestroy()

Declaration
protected virtual void OnDestroy()
| Improve this Doc View Source

PrintID()

Declaration
protected void PrintID()
  • Improve this Doc
  • View Source
Back to top Generated by DocFX