예제 #1
0
        static void GenerateSerializer()
        {
            var info = new ObjectSerialization(typeof(glTF), "gltf", "Deserialize_");

            Debug.Log(info);

            using (var s = File.Open(OutPath, FileMode.Create))
                using (var w = new StreamWriter(s, new UTF8Encoding(false)))
                {
                    w.Write(Begin);
                    info.GenerateDeserializer(w, "Deserialize");
                    w.Write(End);
                }

            Debug.LogFormat("write: {0}", OutPath);
            UnityPath.FromFullpath(OutPath).ImportAsset();
        }
예제 #2
0
        static void GenerateSerializerTypes(System.Type type)
        {
            var name = string.Format("{0}_Deserialize", type.Name);
            var info = new UniGLTF.ObjectSerialization(type, "vci", name);

            Debug.Log(info);

            using (var s = File.Open(GetPath(name), FileMode.Create))
                using (var w = new StreamWriter(s, Encoding.UTF8))
                {
                    w.NewLine = "\n";
                    w.Write(@"
using System;
using System.Collections.Generic;
using UniJSON;
using UnityEngine;
using UniGLTF;
using VCI;
using Object = System.Object;

namespace VCI {

public static class ");
                    w.Write(@"
" + type.Name + "_Deserializer");

                    w.Write(@"
{

");

                    info.GenerateDeserializer(w, "Deserialize");

                    // footer
                    w.Write(@"
} // VciDeserializer
} // VCI
");
                }

            // CRLF を LF に変換して再保存
            File.WriteAllText(GetPath(name), File.ReadAllText(GetPath(name), Encoding.UTF8).Replace("\r\n", "\n"), Encoding.UTF8);

            Debug.LogFormat("write: {0}", GetPath(name));
            UnityPath.FromFullpath(GetPath(name)).ImportAsset();
        }