A* Pathfinding Project  3.1.4
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Enumerations Properties Groups Pages
AstarSerializer Class Reference
+ Inheritance diagram for AstarSerializer:
+ Collaboration diagram for AstarSerializer:

Classes

struct  BitMask
 
class  SMask
 Serializer mask for what is to be saved in the file. More...
 

Public Types

enum  SerializerError { Nothing, WrongMagic, WrongVersion, DoesNotExist }
 

Public Member Functions

 AstarSerializer (AstarPath script)
 
void AddAnchor (string name)
 
virtual void AddUnityReferenceValue (string key, UnityEngine.Object value)
 Serializes a Unity Reference.
 
void AddValue (string key, System.Object value)
 Serializes value with key and value.
 
void AddVariableAnchor (string name)
 
void Close ()
 
byte[] Compress (byte[] bytes)
 
byte[] DeCompress (byte[] bytes)
 
delegate void DeSerializationInterrupt (AstarSerializer serializer, bool newer, Guid guid)
 
void DeserializeAnchors ()
 
void DeSerializeEditorSettings (NavGraph graph, ISerializableGraphEditor editor, AstarPath active)
 
void DeserializeNodes (NavGraph graph, NavGraph[] graphs, int graphIndex, AstarPath active)
 Deserializes nodes in the graph.
 
AstarSerializer DeserializeSerializationInfo ()
 Deserializes serialization info.
 
void DeSerializeSettings (NavGraph graph, AstarPath active)
 
virtual UserConnection[] DeserializeUserConnections ()
 Deserializes links placed by the user.
 
System.Object GetDefaultValue (Type type)
 Returns the default value for the given type.
 
virtual UnityEngine.Object GetUnityReferenceValue (string key, Type type, UnityEngine.Object defaultValue=null)
 Deserializes a Unity Reference.
 
System.Object GetValue (string key, Type type, System.Object defaultValue=null)
 Deserializes a variable with key of the specified type.
 
void InitializeSerializeNodes ()
 
byte[] LoadFromFile (string path)
 
bool MoveToAnchor (string name)
 
bool MoveToVariableAnchor (string name)
 
AstarSerializer OpenDeserialize (byte[] data)
 Opens a deserialization session.
 
void OpenSerialize ()
 This is intended for quick saving of settings for e.g Undo operations.
 
delegate UnityEngine.Object ReadUnityReference_Editor (AstarSerializer serializer, string name, int instanceID, System.Type type)
 
void SaveToFile (string path, byte[] data)
 
void SerializeAnchors ()
 
void SerializeEditorSettings (NavGraph graph, ISerializableGraphEditor editor, AstarPath active)
 
void SerializeNodes (NavGraph graph, AstarPath active)
 Serializes the nodes in the graph.
 
void SerializeSerializationInfo ()
 
void SerializeSettings (NavGraph graph, AstarPath active)
 Called to serialize a graphs settings.
 
virtual void SerializeUserConnections (UserConnection[] userConnections)
 Serializes links placed by the user.
 
void SetUpGraphRefs (NavGraph[] graphs)
 
void Sort (int[] a, byte[] b)
 
void WriteError ()
 
delegate void WriteUnityReference_Editor (AstarSerializer serializer, UnityEngine.Object ob)
 

Static Public Member Functions

static AstarSerializer GetDeserializer (Version version, AstarPath script)
 
static string StripPathOfFolder (string path, string relativeFolder)
 Makes path relative to the folder relativeFolder when relativeFolder exists in path.
 
static void TestLoadFile (string path)
 

Public Attributes

AstarPath active
 
Dictionary< string, int > anchors
 
AstarData astarData
 
bool compress = true
 
int counter
 
SerializerError error = SerializerError.Nothing
 
int[] graphRefGuids
 The indices to the graphs in the new AstarData.
 
string[] loadedGraphGuids
 The GUIDs of the graphs saved with the file (only set in load)
 
BitMask mask = -1 & ~(SMask.SaveNodes)
 Mask for what to save.
 
bool onlySaveSettings = false
 
int positionAtCounter = -1
 
long positionAtError = -1
 
byte prefix = 0
 
BinaryReader readerStream
 
bool replaceOldGraphs = true
 
Hashtable serializedData
 
Dictionary< string, int > serializedVariables = new Dictionary<string, int> ()
 Key, position.
 
string sPrefix = ""
 Prefix to use before variables.
 
BinaryWriter writerStream
 

Static Public Attributes

static bool IgnoreVersionDifferences = false
 Should version differences be ignored.
 
static ReadUnityReference_Editor readUnityReference_Editor = null
 
static WriteUnityReference_Editor writeUnityReference_Editor = null
 

Private Member Functions

void DeSerializeNode (Node node, NavGraph[] graphs, int graphIndex, BinaryReader stream)
 Deserializes one node from the stream into the specified graphs and to the specified graph index.
 
void SerializeNode (Node node, BinaryWriter stream)
 Serializes one node to the stream.
 

Private Attributes

List< int > tmpConnectionCosts
 
List< NodetmpConnections
 

Detailed Description

Bug:
Sometimes Unity references will reference a different object (or empty object) when loaded back again. Probably because the Object.GetInstanceID values are changed on the objects in the project. This might result in that the "Root" object on the Point graph or the "Mesh" object on the Navmesh graph is set to null or to another object sometimes (quite rare though).

Member Function Documentation

virtual void AddUnityReferenceValue ( string  key,
UnityEngine.Object  value 
)
virtual

Serializes a Unity Reference.

Serializer references such as Transform, GameObject, Texture or other unity objects

Reimplemented in AstarSerializer3_07.

void DeSerializeNode ( Node  node,
NavGraph[]  graphs,
int  graphIndex,
BinaryReader  stream 
)
private

Deserializes one node from the stream into the specified graphs and to the specified graph index.

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void DeserializeNodes ( NavGraph  graph,
NavGraph[]  graphs,
int  graphIndex,
AstarPath  active 
)

Deserializes nodes in the graph.

The deserialized nodes will be created using graph.CreateNodes (numberOfNodes).

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AstarSerializer DeserializeSerializationInfo ( )

Deserializes serialization info.

Deserializes Version, mask and loadedGraphGuids

See Also
OpenDeserialize

+ Here is the caller graph for this function:

virtual UnityEngine.Object GetUnityReferenceValue ( string  key,
Type  type,
UnityEngine.Object  defaultValue = null 
)
virtual

Deserializes a Unity Reference.

Deserializes references such as Transform, GameObject, Texture or other unity objects

Reimplemented in AstarSerializer3_07.

+ Here is the call graph for this function:

AstarSerializer OpenDeserialize ( byte[]  data)

Opens a deserialization session.

This function returns an AstarSerializer, it will usually be the same as called on, but when loading from older graphs, it will have been replaced by another one.
Use the returned AstarSerializer from now on

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SerializeNode ( Node  node,
BinaryWriter  stream 
)
private

Serializes one node to the stream.

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here

+ Here is the caller graph for this function:

void SerializeNodes ( NavGraph  graph,
AstarPath  active 
)

Serializes the nodes in the graph.

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here

+ Here is the call graph for this function:

void SerializeSettings ( NavGraph  graph,
AstarPath  active 
)

Called to serialize a graphs settings.

Note
Before calling this, setting sPrefix to something unique for the graph is a good idea to avoid collisions in variable names

+ Here is the call graph for this function:

static string StripPathOfFolder ( string  path,
string  relativeFolder 
)
static

Makes path relative to the folder relativeFolder when relativeFolder exists in path.

A path folder1/someFolder/testingFolder/myPic.png with relativeFolder = "someFolder" would become testingFolder/myPic.png
Returns "" (empty string) if the path didn't contain relativeFolder

Member Data Documentation

int [] graphRefGuids

The indices to the graphs in the new AstarData.

Conversion from loaded indices (newGraphIndex = graphRefGuids[oldGraphIndex])

bool IgnoreVersionDifferences = false
static

Should version differences be ignored.

This should not be enabled if you don't know what you are doing. It will enable older version of the project to try open files saved with a newer project version

BitMask mask = -1 & ~(SMask.SaveNodes)

Mask for what to save.

The first 4 bits in this mask is used, the rest can be used to pass information on what was saved in the file *Assign values with += or |=, and remove them with -= or &= ~value Values should be one bit values (unless you know what you are doing), such as 1 << 20

string sPrefix = ""

Prefix to use before variables.

Used to avoid name collisions


The documentation for this class was generated from the following file: