Exemplo n.º 1
0
        public void GenerateMetaFile(string path)
        {
            if (!File.Exists(path) || Path.GetExtension(path) != ".h")
            {
                return;
            }

            try
            {
                string content = File.ReadAllText(path);
                string log     = "";
                string json    = MetaCpp.GenerateMetaComponentJson(content, out log);
                if (String.IsNullOrEmpty(json))
                {
                    DoAction(new Action("RemoveMetaComponent", path), true);
                }
                else
                {
                    File.WriteAllText(path + ".meta", json);
                    DoAction(new Action("LoadMetaComponent", path), true);
                }
                json = MetaCpp.GenerateMetaAssetJson(content, out log);
                if (String.IsNullOrEmpty(json))
                {
                    DoAction(new Action("RemoveMetaAsset", path), true);
                }
                else
                {
                    File.WriteAllText(path + ".meta", json);
                    DoAction(new Action("LoadMetaAsset", path), true);
                }
            }
            catch { }
        }
Exemplo n.º 2
0
        private static void ProcessFile(string input, string output, string type)
        {
            if (string.IsNullOrEmpty(input))
            {
                return;
            }
            input = Path.GetFullPath(input);
            if (string.IsNullOrEmpty(output))
            {
                output = input;
            }
            if (Path.GetExtension(output) != ".meta")
            {
                output += ".meta";
            }

            string content = File.ReadAllText(input);
            string log     = "";
            string json    = null;

            if (type == "-component" || type == "-c")
            {
                json = MetaCpp.GenerateMetaComponentJson(content, out log);
            }
            else if (type == "-asset" || type == "-a")
            {
                json = MetaCpp.GenerateMetaAssetJson(content, out log);
            }
            if (json != null)
            {
                Console.WriteLine();
                Console.WriteLine("Input: " + input);
                Console.WriteLine("Output: " + output);
                File.WriteAllText(output, json);
            }
        }