示例#1
0
 public SkylessDumpTool(SkylessSerializer serializer)
 {
     this.skylessSerializer = serializer;
 }
示例#2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                PrintUsageAndExit();
            }

            string command = args[0].ToLower();

            string dllPath = args[1];

            Console.WriteLine(dllPath);
            string asmPath = null;

            if (File.Exists(dllPath))
            {
                asmPath = dllPath;
            }
            else
            {
                var tempPath = Path.Combine(dllPath, AssemblyName);
                if (File.Exists(tempPath))
                {
                    asmPath = tempPath;
                }
                else
                {
                    PrintUsageAndExit($"Cannot open Assembly-CSharp.dll, check arguments.");
                }
            }

            SkylessSerializer serializer;

            try
            {
                serializer = new SkylessSerializer(asmPath);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine($"Failed to load SkylessSerializer.\n{e.ToString()}");
                return;
            }

            SkylessDumpTool tool = new SkylessDumpTool(serializer);

            tool.LogCallback += Console.WriteLine;

            if (command == "export")
            {
                if (args.Length < 4)
                {
                    PrintUsageAndExit($"Insufficient arguments : expected 4, got {args.Length}");
                }
                CheckFileExists(args[2], "assetPath");

                tool.ExportAllToJson(args[2], args[3]);
                Console.WriteLine($"Exported JSON files to {args[3]}");
            }
            else if (command == "import")
            {
                if (args.Length < 5)
                {
                    PrintUsageAndExit($"Insufficient arguments : expected 5, got {args.Length}");
                }
                CheckFileExists(args[2], "assetPath");

                tool.ImportAllJsonToAsset(args[2], args[3], args[4]);
                Console.WriteLine($"Imported all JSON files to {args[4]}");
            }
            else
            {
                PrintUsageAndExit($"Error : Unknown command {command}");
            }
        }