GetStringBuilder() private static method

private static GetStringBuilder ( ) : System.Text.StringBuilder
return System.Text.StringBuilder
コード例 #1
0
        public byte[] Serialize(NavGraph graph)
        {
            StringBuilder stringBuilder = AstarSerializer.GetStringBuilder();

            TinyJsonSerializer.Serialize(graph, stringBuilder);
            return(this.encoding.GetBytes(stringBuilder.ToString()));
        }
コード例 #2
0
        private byte[] SerializeMeta()
        {
            if (this.graphs == null)
            {
                throw new Exception("No call to SerializeGraphs has been done");
            }
            this.meta.version   = AstarPath.Version;
            this.meta.graphs    = this.graphs.Length;
            this.meta.guids     = new List <string>();
            this.meta.typeNames = new List <string>();
            for (int i = 0; i < this.graphs.Length; i++)
            {
                if (this.graphs[i] != null)
                {
                    this.meta.guids.Add(this.graphs[i].guid.ToString());
                    this.meta.typeNames.Add(this.graphs[i].GetType().FullName);
                }
                else
                {
                    this.meta.guids.Add(null);
                    this.meta.typeNames.Add(null);
                }
            }
            StringBuilder stringBuilder = AstarSerializer.GetStringBuilder();

            TinyJsonSerializer.Serialize(this.meta, stringBuilder);
            return(this.encoding.GetBytes(stringBuilder.ToString()));
        }
コード例 #3
0
        private byte[] SerializeMeta()
        {
            if (this.graphs == null)
            {
                throw new Exception("No call to SerializeGraphs has been done");
            }
            this.meta.version    = AstarPath.Version;
            this.meta.graphs     = this.graphs.Length;
            this.meta.guids      = new string[this.graphs.Length];
            this.meta.typeNames  = new string[this.graphs.Length];
            this.meta.nodeCounts = new int[this.graphs.Length];
            for (int i = 0; i < this.graphs.Length; i++)
            {
                if (this.graphs[i] != null)
                {
                    this.meta.guids[i]     = this.graphs[i].guid.ToString();
                    this.meta.typeNames[i] = this.graphs[i].GetType().FullName;
                }
            }
            StringBuilder stringBuilder = AstarSerializer.GetStringBuilder();
            JsonWriter    jsonWriter    = new JsonWriter(stringBuilder, this.writerSettings);

            jsonWriter.Write(this.meta);
            return(this.encoding.GetBytes(stringBuilder.ToString()));
        }
コード例 #4
0
        public byte[] Serialize(NavGraph graph)
        {
            StringBuilder stringBuilder = AstarSerializer.GetStringBuilder();
            JsonWriter    jsonWriter    = new JsonWriter(stringBuilder, this.writerSettings);

            jsonWriter.Write(graph);
            return(this.encoding.GetBytes(stringBuilder.ToString()));
        }
コード例 #5
0
        public void SerializeUserConnections(UserConnection[] conns)
        {
            if (conns == null)
            {
                conns = new UserConnection[0];
            }
            StringBuilder stringBuilder = AstarSerializer.GetStringBuilder();
            JsonWriter    jsonWriter    = new JsonWriter(stringBuilder, this.writerSettings);

            jsonWriter.Write(conns);
            byte[] bytes = this.encoding.GetBytes(stringBuilder.ToString());
            if (bytes.Length <= 2)
            {
                return;
            }
            this.AddChecksum(bytes);
            this.zip.AddEntry("connections.json", bytes);
        }
コード例 #6
0
 public void SerializeEditorSettings(GraphEditorBase[] editors)
 {
     if (editors == null || !this.settings.editorSettings)
     {
         return;
     }
     for (int i = 0; i < editors.Length; i++)
     {
         if (editors[i] == null)
         {
             return;
         }
         StringBuilder stringBuilder = AstarSerializer.GetStringBuilder();
         TinyJsonSerializer.Serialize(editors[i], stringBuilder);
         byte[] bytes = this.encoding.GetBytes(stringBuilder.ToString());
         if (bytes.Length > 2)
         {
             this.AddChecksum(bytes);
             this.AddEntry("graph" + i + "_editor.json", bytes);
         }
     }
 }