Ejemplo n.º 1
0
    public byte[] SerializeGraphs(Pathfinding.Serialize.SerializeSettings settings, out uint checksum)
    {
        Pathfinding.Serialize.AstarSerializer sr = new Pathfinding.Serialize.AstarSerializer(script.astarData, settings);
        sr.OpenSerialize();
        script.astarData.SerializeGraphsPart (sr);
        sr.SerializeEditorSettings (graphEditors);
        byte[] bytes = sr.CloseSerialize();
        checksum = sr.GetChecksum ();
        return bytes;

        //Forward to runtime serializer
        //return script.astarData.SerializeGraphs(Pathfinding.Serialize.SerializeSettings.Settings, out checksum);
    }
Ejemplo n.º 2
0
    public void DeserializeGraphs(byte[] bytes)
    {
        Pathfinding.Serialize.AstarSerializer sr = new Pathfinding.Serialize.AstarSerializer(script.astarData);
        if (sr.OpenDeserialize(bytes)) {
            script.astarData.DeserializeGraphsPart (sr);

            //Make sure every graph has a graph editor
            CheckGraphEditors ();
            sr.DeserializeEditorSettings (graphEditors);

            sr.CloseDeserialize();
        } else {
            Debug.Log ("Invalid data file (cannot read zip). Trying to load with old deserializer (pre 3.1)...");
            AstarSerializer serializer = new AstarSerializer (script);
            script.astarData.DeserializeGraphs_oldInternal (serializer,bytes);

            //Make sure every graph has a graph editor
            CheckGraphEditors ();
        }

        /*serializer = serializer.OpenDeserialize (data);

        //Deserialize the main bulk of the data
        script.astarData.DeserializeGraphsPart (serializer);

        CheckGraphEditors ();

        //Deserialize editor data
        for (int i=0;i<script.graphs.Length;i++) {
            NavGraph graph = script.graphs[i];

            GraphEditor graphEditor = graphEditors[i];

            if (serializer.MoveToAnchor ("EditorSettings_"+i)) {
                ISerializableGraphEditor serializableEditor = graphEditor as ISerializableGraphEditor;
                if (serializableEditor != null) {
                    //Set an unique prefix for all variables in this graph
                    serializer.sPrefix = i.ToString ()+"E";
                    serializer.DeSerializeEditorSettings (graph,serializableEditor,script);
                    //serializableEditor.DeSerializeSettings (graph,serializer);
                }
            }
        }

        serializer.Close ();*/

        //script.astarData.DeserializeGraphs(data);
    }
Ejemplo n.º 3
0
    public byte[] SerializeGraphs(Pathfinding.Serialize.SerializeSettings settings, out uint checksum)
    {
        Pathfinding.Serialize.AstarSerializer sr = new Pathfinding.Serialize.AstarSerializer(script.astarData, settings);
        sr.OpenSerialize();
        script.astarData.SerializeGraphsPart (sr);
        sr.SerializeEditorSettings (graphEditors);
        byte[] bytes = sr.CloseSerialize();
        checksum = sr.GetChecksum ();
        #if DEBUG
        Debug.Log ("Got a whole bunch of data, "+bytes.Length+" bytes");
        #endif
        return bytes;

        //Forward to runtime serializer
        //return script.astarData.SerializeGraphs(Pathfinding.Serialize.SerializeSettings.Settings, out checksum);
    }