Adventure Creator  1.79.1
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2022
AC.Serializer Class Reference
Inheritance diagram for AC.Serializer:

Static Public Member Functions

static T returnComponent< T > (int constantID)
 
static ConstantID returnConstantID (int constantID)
 
static T GetGameObjectComponent< T > (int constantID, GameObject gameObject)
 Gets a component on a GameObject, or a child of that GameObject, with a given ConstantID. More...
 
static int GetConstantID (GameObject _gameObject, bool reportMissing=true)
 Gets the Constant ID number of a GameObject, if it has one. More...
 
static int GetConstantID (Transform _transform)
 Gets the Constant ID number of a Transform, if it has one. More...
 
static string SerializeObject< T > (object dataObject, bool addMethodName=false, iFileFormatHandler fileFormatHandler=null)
 Serializes an object, either by XML, Binary or Json, depending on the game's iFileFormatHandler. More...
 
static T DeserializeObject< T > (string dataString, iFileFormatHandler fileFormatHandler=null)
 De-serializes an object from a string, according to the game's iFileFormatHandler. More...
 
static Paths RestorePathData (Paths path, string pathData)
 Converts a compressed string into an array of Paths object's nodes. More...
 
static string CreatePathData (Paths path)
 Compresses a Paths object's nodes into a single string, that can be stored in a save file. More...
 
static bool SaveFile (string fullFileName, string _data)
 
static string LoadFile (string fullFilename, bool doLog=true)
 
static string SaveScriptData< T > (object dataObject)
 Serializes a Remember script object, either XML, Binary or Json, depending on the platform. More...
 
static T LoadScriptData< T > (string dataString)
 De-serializes a RememberData class. More...
 
static OptionsData DeserializeOptionsData (string dataString)
 Deserializes a string into an OptionsData class. More...
 

Detailed Description

All of AC's actual file handling, serialising and deserialising is performed within this script. Its public functions are static, so it does not need to be placed on any scene object.

Member Function Documentation

◆ CreatePathData()

static string AC.Serializer.CreatePathData ( Paths  path)
static

Compresses a Paths object's nodes into a single string, that can be stored in a save file.

Parameters
pathThe Paths object to compress
Returns
The compressed string

◆ DeserializeObject< T >()

static T AC.Serializer.DeserializeObject< T > ( string  dataString,
iFileFormatHandler  fileFormatHandler = null 
)
static

De-serializes an object from a string, according to the game's iFileFormatHandler.

Parameters
dataStringThe object, serialized into a string
fileFormatHandlerThe iFileFormatHandler to use to deserialize the data. If not set, it will default to SaveSystem.FileFormatHandler
Returns
The object, deserialized

◆ DeserializeOptionsData()

static OptionsData AC.Serializer.DeserializeOptionsData ( string  dataString)
static

Deserializes a string into an OptionsData class.

Parameters
dataStringThe OptionsData, serialized as a string
Returns
The de-serialized OptionsData class

◆ GetConstantID() [1/2]

static int AC.Serializer.GetConstantID ( GameObject  _gameObject,
bool  reportMissing = true 
)
static

Gets the Constant ID number of a GameObject, if it has one.

Parameters
_gameObjectThe GameObject to check for
Returns
The Constant ID number (generated by a ConstantID script), if it has one. Returns 0 otherwise.

◆ GetConstantID() [2/2]

static int AC.Serializer.GetConstantID ( Transform  _transform)
static

Gets the Constant ID number of a Transform, if it has one.

Parameters
_transformThe Transform to check for
Returns
The Constant ID number (generated by a ConstantID script), if it has one. Returns 0 otherwise.

◆ GetGameObjectComponent< T >()

static T AC.Serializer.GetGameObjectComponent< T > ( int  constantID,
GameObject  gameObject 
)
static

Gets a component on a GameObject, or a child of that GameObject, with a given ConstantID.

Parameters
constantIDThe Constant ID number generated by the ConstantID component
_gameObjectThe GameObject to search
Returns
The component on the GameObject, or a child of that GameObject, with a given ConstantID
Type Constraints
T :Component 

◆ LoadScriptData< T >()

static T AC.Serializer.LoadScriptData< T > ( string  dataString)
static

De-serializes a RememberData class.

Parameters
dataStringThe RememberData class, serialized as a string
Returns
The de-serialized RememberData class</return>
Type Constraints
T :RememberData 

◆ RestorePathData()

static Paths AC.Serializer.RestorePathData ( Paths  path,
string  pathData 
)
static

Converts a compressed string into an array of Paths object's nodes.

Parameters
pathThe Paths object to send the results to
pathDataThe compressed string
Returns
The Paths object, with the recreated nodes

◆ returnComponent< T >()

static T AC.Serializer.returnComponent< T > ( int  constantID)
static

Deprecated - use ConstantID.GetComponent instead

Type Constraints
T :Component 

◆ returnConstantID()

static ConstantID AC.Serializer.returnConstantID ( int  constantID)
static

Deprecated - use ConstantID.GetComponent instead

◆ SaveScriptData< T >()

static string AC.Serializer.SaveScriptData< T > ( object  dataObject)
static

Serializes a Remember script object, either XML, Binary or Json, depending on the platform.

Parameters
dataObjectThe object to serialize
Returns
The object, serialized to a string
Type Constraints
T :RememberData 

◆ SerializeObject< T >()

static string AC.Serializer.SerializeObject< T > ( object  dataObject,
bool  addMethodName = false,
iFileFormatHandler  fileFormatHandler = null 
)
static

Serializes an object, either by XML, Binary or Json, depending on the game's iFileFormatHandler.

Parameters
dataObjectThe object to serialize
addMethodNameIf True, the name of the serialization method (XML, Binary or Json) will be appended to the start of the serialized string. This is useful when the same file is read later by a different serialization method.
fileFormatHandlerThe iFileFormatHandler to use to serialize the data. If not set, it will default to SaveSystem.FileFormatHandler
Returns
The object, serialized to a string