Example #1
0
        public static void HandleProto(string protoFile)
        {
            var p         = new Process();
            var startInfo = p.StartInfo;

            startInfo.FileName = Application.dataPath + "/Plugins/LTGame/Editor/Utils/ProtoGen/protoc.exe";
            var savePath = LTEditorUtils.GetRealPath(LTEditorData.instance.protoGenPath);

            LTUtils.MakeDirExist(savePath);
            var protoDirPath = LTUtils.GetDirPath(protoFile);
            var arguments    = string.Format(" --csharp_out={0} --proto_path {1} {2}", savePath, protoDirPath, protoFile);

            // arguments = arguments.ReplaceAll("/", "\\\\");
            UnityEngine.Debug.LogFormat("arguments:{0}", arguments);
            startInfo.Arguments             = arguments;
            startInfo.RedirectStandardError = true;
            startInfo.UseShellExecute       = false;
            p.Start();
            var errorStr = p.StandardError.ReadToEnd();

            p.WaitForExit();

            if (string.IsNullOrEmpty(errorStr))
            {
                UnityEngine.Debug.LogFormat("生成{0}到{1}", protoFile, savePath);
            }
            else
            {
                UnityEngine.Debug.LogErrorFormat("errorOutput:{0}", errorStr);
                UnityEngine.Debug.LogErrorFormat("生成{0}到{1}失败", protoFile, savePath);
            }
        }
Example #2
0
        private static LTDirInfo _Init(string fullDirPath)
        {
            var dirPath   = LTUtils.GetDirPath(fullDirPath);
            var splitDirs = dirPath.Split("/");
            var dirList   = new LTDirInfo[splitDirs.Length];

            for (var i = 0; i < dirList.Length; ++i)
            {
                var splitDir = splitDirs[i];
                var dir      = new LTDirInfo(splitDir);
                dirList[i] = dir;
            }
            for (var i = 1; i < dirList.Length; ++i)
            {
                dirList[i - 1].Connect(dirList[i]);
            }
            return(dirList[splitDirs.Length - 1]);
        }