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

Static Public Member Functions

static T returnComponent< T > (int constantID, GameObject sceneObject=null)
 Gets a component on a GameObject in the scene that also has a ConstantID component on it. More...
 
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 T [] returnComponents< T > (int constantID, GameObject gameObject=null)
 Gets all given components on GameObjects that have a given Constant ID. More...
 
static int GetConstantID (GameObject _gameObject)
 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)
 Serializes an object, either by XML, Binary or Json, depending on the game's iFileFormatHandler. More...
 
static T DeserializeObject< T > (string dataString)
 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)
static

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

Parameters
dataStringThe object, serialized into a string
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)
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,
GameObject  sceneObject = null 
)
static

Gets a component on a GameObject in the scene that also has a ConstantID component on it.

Parameters
constantIDThe Constant ID number generated by the ConstantID component
sceneObjectAn object that, if set, must also be in the same scene as the returned component
Returns
The component on the GameObject with a Constant ID number that matches the request. If none is found, returns null.
Type Constraints
T :Component 

◆ returnComponents< T >()

static T [] AC.Serializer.returnComponents< T > ( int  constantID,
GameObject  gameObject = null 
)
static

Gets all given components on GameObjects that have a given Constant ID.

Parameters
constantIDThe Constant ID number generated by the ConstantID component
Returns
All components on the GameObject with a Constant ID number that matches the request. If none is found, returns null.
Type Constraints
T :Component 

◆ 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 
)
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.
Returns
The object, serialized to a string