public ShellHelper.ShellRequest Compile(string input)
 {
     if (Application.platform == RuntimePlatform.OSXEditor)
     {
         if (luaCompiler.EndsWith("luac"))
         {
             ShellHelper.ShellRequest req = ShellHelper.ProcessCommand("find " + input + " -name '*.lua' -exec " + this.luaCompiler + " -o {}.txt {} \\;", "./");
             return(req);
         }
         else
         {
             ShellHelper.ShellRequest req = ShellHelper.ProcessCommand("find " + input + " -name '*.lua' -exec " + this.luaCompiler + " -b {} {}.txt \\;", "./");
             return(req);
         }
     }
     else
     {
         if (luaCompiler.EndsWith("luac"))
         {
             ShellHelper.ShellRequest req = ShellHelper.ProcessCommand(@"FOR %I IN (" + input + @"\*.lua) " + @" DO " + this.luaCompiler + @" -o ""%I.txt"" ""%I"" ", ".");
             return(req);
         }
         else
         {
             ShellHelper.ShellRequest req = ShellHelper.ProcessCommand(@"FOR %I IN (" + input + @"\*.lua) " + @" DO " + this.luaCompiler + @" -b ""%I"" ""%I.txt"" ", ".");
             return(req);
         }
     }
 }
Пример #2
0
    static void DoPackerCommond(AtlasConfig config)
    {
        if (config == null)
        {
            return;
        }
        string cmd = TexturePackerCommond.GetPackCommond(config.PhotosFolderPath, config.PhotoFullPath, config.AtlasTxtFullPath);

        ShellHelper.ShellRequest request = ShellHelper.ProcessCommand(cmd, null);
        EditorUtility.DisplayProgressBar("批量处理中...", "Shell脚本生成图集信息...", 0);
        request.onDone += () =>
        {
            if (replaceAtlasConfigList.Count > 0)
            {
                AtlasConfig next_config = replaceAtlasConfigList.Dequeue();
                DoPackerCommond(next_config);
            }
            else
            {
                EditorUtility.DisplayProgressBar("批量处理中...", "Shell脚本执行完毕...开始打图集...", 0);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                BatchCreateUIAtlasPrefabs();
            }
        };
        request.onError += () =>
        {
            Debug.LogError("Texture Packer Error!!! Please Check Your Config");
        };
    }
Пример #3
0
    public static void ls()
    {
#if UNITY_EDITOR_OSX
        ShellHelper.ShellRequest req = ShellHelper.ProcessCommand("ls", "");
        req.onLog += delegate(int arg1, string arg2) {
            Debug.Log(arg2);
        };
#endif
    }
Пример #4
0
 static void runBash(string command, string workdir)
 {
     try {
         ShellHelper.ShellRequest req = ShellHelper.ProcessCommand(command, workdir);
         req.onLog += delegate(int logType, string log) {
             debugLog(log);
         };
         req.onDone += delegate {
             debugLog("command finished");
         };
     } catch (IOException e) {
         debugLog("please ignore the exception and wait until xcarchive done");
     }
 }
    public ShellHelper.ShellRequest Compile(params string[] inputs)
    {
        ShellHelper.ShellRequest req = new ShellHelper.ShellRequest();
        int completeCount            = 0;

        foreach (string input in inputs)
        {
            ShellHelper.ShellRequest reqI = Compile(input);
            reqI.onDone += delegate() {
                completeCount++;
                if (completeCount == inputs.Length)
                {
                    req.NotifyDone();
                }
            };
        }
        return(req);
    }
    [PostProcessBuild(1)] // this means this method will be called just after the build is finished
    public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
    {
        // This method will create a new text file to the build folder, that will have the current time
        // and last git commit information

        var infoPath = Path.GetDirectoryName(pathToBuiltProject) + "/info.txt";

        // Time
        StringBuilder info = new StringBuilder();

        info.AppendLine("-- Time --");
        info.AppendLine(DateTime.Now.ToString("MM.dd. yyyy HH:mm"));
        info.AppendLine("-");

        // Last Commit
        ShellHelper.ShellRequest req = ShellHelper.ProcessCommand("git log -1", Application.dataPath);
        int numLines = 0;

        req.onLog += (logType, log) =>
        {
            if (numLines == 0)
            {
                info.AppendLine("-- Last Commit --");
            }
            info.AppendLine(log);
            numLines++;
        };

        int numDone = 0;

        req.onDone += () =>
        {
            numDone++;
            if (numDone == 2)
            {
                File.WriteAllText(infoPath, info.ToString(), Encoding.UTF8);
            }
        };
    }
Пример #7
0
    /// <summary>
    /// 打Unity格式图集
    /// </summary>
    private void UnitySpriteTexturePacker()
    {
        curTime = System.DateTime.Now;
        string cmd = TexturePackerCommond.GetPackCommond(arangeSpritesFolderPath, arrangeIconAtlasPngPath, arrangeIconAtlasTpsheetFilePath);

        ShellHelper.ShellRequest request = ShellHelper.ProcessCommand(cmd, null);
        EditorUtility.DisplayProgressBar("批量处理中...", "Shell脚本生成Json图集信息...", 0);
        request.onDone += () =>
        {
            {
                EditorUtility.DisplayProgressBar("批量处理中...", "Shell脚本执行完毕...开始打图集...", 0);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                CreateUIAtlas();
            }
        };
        request.onError += () =>
        {
            Debug.LogError("Texture Packer Error!!! Please Check Your Config");
            EditorUtility.ClearProgressBar();
        };
    }
    public void BuildWithByteCode(string outputDir, string[] inputs, BuildTarget targetPlatform)
    {
        if (!System.IO.Directory.Exists(outputDir))
        {
            System.IO.Directory.CreateDirectory(outputDir);
        }

        ShellHelper.ShellRequest req = Compile(inputs);
        req.onDone += delegate() {
            AssetDatabase.Refresh();
            List <AssetBundleBuild> buildInfos = new List <AssetBundleBuild>();
            foreach (string input in inputs)
            {
                string           bundleName = System.IO.Path.GetFileName(input);
                string[]         luaFiles   = System.IO.Directory.GetFiles(input, "*.lua.txt", System.IO.SearchOption.AllDirectories);
                AssetBundleBuild bd         = new AssetBundleBuild();
                bd.assetBundleName = bundleName;
                bd.assetNames      = luaFiles;
                buildInfos.Add(bd);
            }

            AssetDatabase.Refresh();

            BuildPipeline.BuildAssetBundles(outputDir, buildInfos.ToArray(), BuildAssetBundleOptions.None, targetPlatform);
            //delete temp files ,
            foreach (AssetBundleBuild bd in buildInfos)
            {
                foreach (string file in bd.assetNames)
                {
                    FileUtil.DeleteFileOrDirectory(file);
                }
            }
            string outputDirName = System.IO.Path.GetFileName(outputDir);
            RenameFile(outputDir + "/" + outputDirName, outputDir + "/LuaPlugins");
            RenameFile(outputDir + "/" + outputDirName + ".manifest", outputDir + "/LuaPlugins.manifest");

            AssetDatabase.Refresh();
        };
    }
Пример #9
0
    static void GenerateAuthProto()
    {
        {
            Debug.Log("生成Auth相关的CS文件");
            string command = "";
#if UNITY_EDITOR_OSX
            command = "./Assets/Plugins/ProtoCompiler/macOS/protoc"
                      + " --csharp_out=./Assets/Scripts/Network"
                      + " ./Assets/Scripts/Network/auth.proto";
#elif UNITY_EDITOR_WIN
            command = Path.Combine(Application.dataPath, "Plugins/ProtoCompiler/Windows/protoc.exe")
                      + $" --csharp_out={Path.Combine(Application.dataPath, "Scripts/Network")}"
                      + $" -I={Path.Combine(Application.dataPath, "Scripts/Network")} auth.proto";
#endif
            ShellHelper.ShellRequest req = ShellHelper.ProcessCommand(command, "");
            req.onLog += delegate(int arg1, string arg2) {
                Debug.Log(arg2);
            };
            req.onDone += delegate() {
                AssetDatabase.Refresh();
            };
        }
    }
Пример #10
0
        private static void LinkFloder()
        {
            string sourseFloder = EditorUtility.OpenFolderPanel("选择源文件夹", PathUtil.ApplicationBasePath, "");

            if (string.IsNullOrEmpty(sourseFloder))
            {
                Debug.Log("无效的路径");
                return;
            }

            string toPath       = PathUtil.AssetPath2FullPath(AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]));
            string toFolderPath = Path.Combine(toPath, Path.GetFileName(sourseFloder));

            if (Directory.Exists(toFolderPath))
            {
                throw new ArgumentException("操作终止" + toPath + " 路径下已存在同名文件夹:" + Path.GetFileName(sourseFloder));
            }

            // 判断是否Mac平台,在Module DLL 下不能用 PlatformEditor.IsOSXPlatform来判断.
            bool isOsx = sourseFloder.StartsWith("/");

//            Debug.Log(isOsx);
            if (!isOsx)
            {
                sourseFloder = sourseFloder.Replace("/", "\\");
                toFolderPath = toFolderPath.Replace("/", "\\");
                string cmd = string.Format("mklink /j {0} {1} & echo ok", toFolderPath, sourseFloder);

                string result = ShellUtil.RunCmdCommand(cmd);
                if (result.Contains("<<===>>"))
                {
                    AssetDatabase.Refresh();
                }
                else
                {
                    Debug.LogError("操作可能出错,请自行检查");
                }
            }
            else
            {
                sourseFloder = sourseFloder.Replace("\\", "/");
                toFolderPath = toFolderPath.Replace("\\", "/");

                string cmd = string.Format("ln -s {0} {1}", sourseFloder, toFolderPath);

                ShellHelper.ShellRequest req = ShellHelper.ProcessCommand(cmd, "");
                req.onLog  += delegate(int arg1, string arg2) { Debug.Log(arg2); };
                req.onDone += delegate()
                {
                    Debug.Log("success");
                    AssetDatabase.Refresh();
                };
                req.onError += delegate { Debug.LogError("link fail."); };

//                var files = KitUtility.GetFiles(sourseFloder);
//                Debug.Log("sources:" + sourseFloder);
//                foreach (var file in files)
//                {
//                    Debug.Log(file);
//                    if (Path.GetFileName(file) == ".DS_Store")
//                    {
//                        continue;
//                    }
//
//                    var tmp = file.Replace("\\", "/");
//                    var target = tmp.Replace(sourseFloder, toFolderPath);
//                    var targetDir = Path.GetDirectoryName(target);
//
//                    Debug.Log("target:" + target);
//                    Debug.Log("dir:" + targetDir);
//                    if (!Directory.Exists(targetDir))
//                    {
//                        Directory.CreateDirectory(targetDir);
////                        AssetDatabase.Refresh();
//                    }
//
//                    ExecuteMacLink(file, target);
//                    AssetDatabase.Refresh();
//                }
            }
        }
Пример #11
0
 public ShellHelper.ShellRequest Compile(params string[] inputs)
 {
     ShellHelper.ShellRequest req = new ShellHelper.ShellRequest();
     int completeCount = 0;
     foreach(string input in inputs){
         ShellHelper.ShellRequest reqI = Compile(input);
         reqI.onDone += delegate() {
             completeCount ++;
             if(completeCount == inputs.Length){
                 req.NotifyDone();
             }
         };
     }
     return req;
 }
Пример #12
0
    public static void DoLuac()
    {
        try
        {
            var sourceDir = Application.dataPath + "/ABRes/Lua";
            var dstDir    = Application.dataPath + "/ABRes/PlayGround/script";
            // var dstDir32 = dstDir + "/luas32";
            // var dstDir64 = dstDir + "/luas64";
            var dstDir32_64 = dstDir + "/luas32_64";

            var projectBase = Directory.GetParent(Application.dataPath).ToString();

#if UNITY_EDITOR_WIN
            // string luac32Build = projectBase + "/Tools/lua-5.3.4_Win32/luac53.exe";
            // string luac64Build = projectBase + "/Tools/lua-5.3.4_Win64/luac53.exe";
            string luac32_64Build = projectBase + "/Tools/lua-5.3.5_Win32_64/luac.exe";
#elif UNITY_EDITOR_OSX
            // string luac32Build = projectBase + "/Tools/lua-5.3.4_darwin32/luac";
            // string luac64Build = projectBase + "/Tools/lua-5.3.4_darwin64/luac";
            string luac32_64Build = projectBase + "/Tools/lua-5.3.5_darwin32_64/luac";
#endif


            // if (Directory.Exists(dstDir32))
            // {
            //     FileUtility.DeleteDirectory(dstDir32, true);
            // }

            // if (Directory.Exists(dstDir64))
            // {
            //     FileUtility.DeleteDirectory(dstDir64, true);
            // }

            if (Directory.Exists(dstDir32_64))
            {
                FileUtility.DeleteDirectory(dstDir32_64, true);
            }

            ShellHelper.CreateWait();
            try
            {
#if UNITY_EDITOR_OSX
                // ShellHelper.ProcessCommand(string.Format("chmod 777 {0} ", luac32Build), "");
                // ShellHelper.ProcessCommand(string.Format("chmod 777 {0} ", luac64Build), "");
                ShellHelper.ProcessCommand(string.Format("chmod 777 {0} ", luac32_64Build), "");
#endif

                var luaFiles = Directory.GetFiles(sourceDir, "*.lua", SearchOption.AllDirectories);
                foreach (var eachLua in luaFiles)
                {
                    //lua file name cannot contain +
                    if (eachLua.Contains("+"))
                    {
                        throw new ArgumentException(string.Format("Lua File Name cannot contain '+' [{0}].", eachLua));
                    }

                    var flatten = eachLua.Substring(sourceDir.Length);

                    // var targetPath32 = dstDir32 + flatten;
                    // {
                    //     var dstParentDir = Directory.GetParent(targetPath32);
                    //     if (!dstParentDir.Exists)
                    //     {
                    //         Directory.CreateDirectory(dstParentDir.ToString());
                    //     }
                    // }

                    // var targetPath64 = dstDir64 + flatten;
                    // {
                    //     var dstParentDir = Directory.GetParent(targetPath64);
                    //     if (!dstParentDir.Exists)
                    //     {
                    //         Directory.CreateDirectory(dstParentDir.ToString());
                    //     }
                    // }

                    var targetPath32_64 = dstDir32_64 + flatten;
                    {
                        var dstParentDir = Directory.GetParent(targetPath32_64);
                        if (!dstParentDir.Exists)
                        {
                            Directory.CreateDirectory(dstParentDir.ToString());
                        }
                    }

                    // {
                    //     ShellHelper.ShellRequest req = ShellHelper.ProcessCommand(string.Format("{0} -o {1} {2}", luac32Build, targetPath32, eachLua), "");
                    //     req.onLog += delegate (int arg1, string arg2)
                    //     {
                    //         if (arg1 > 0)
                    //         {
                    //             XiimoonLog.LogErrorFormat(arg2);

                    //             throw new Exception("Luac Error.");
                    //         }
                    //     };
                    //     req.onEdge += delegate ()
                    //     {
                    //         File.Move(targetPath32, targetPath32.Replace(".lua", ".txt"));
                    //     };
                    // }

                    // {
                    //     ShellHelper.ShellRequest req = ShellHelper.ProcessCommand(string.Format("{0} -o {1} {2}", luac64Build, targetPath64, eachLua), "");
                    //     req.onLog += delegate (int arg1, string arg2)
                    //     {
                    //         if (arg1 > 0)
                    //         {
                    //             XiimoonLog.LogErrorFormat(arg2);

                    //             throw new Exception("Luac Error.");
                    //         }
                    //     };

                    //     req.onEdge += delegate ()
                    //     {
                    //         File.Move(targetPath64, targetPath64.Replace(".lua", ".txt"));
                    //     };
                    // }

                    {
                        ShellHelper.ShellRequest req = ShellHelper.ProcessCommand(string.Format("{0} -o {1} {2}", luac32_64Build, targetPath32_64, eachLua), "");
                        req.onLog += delegate(int arg1, string arg2)
                        {
                            if (arg1 > 0)
                            {
                                Debug.LogErrorFormat(arg2);

                                throw new Exception("Luac Error.");
                            }
                        };

                        req.onEdge += delegate()
                        {
                            File.Move(targetPath32_64, targetPath32_64.Replace(".lua", ".bytes"));
                        };
                    }
                }
            }
            finally
            {
                if (!ShellHelper.Wait())
                {
                    Debug.LogErrorFormat("DoLuac 超时!");
                }
            }

            UnityEditor.AssetDatabase.Refresh();
        }
        catch (Exception e)
        {
            Debug.LogErrorFormat(e.ToString());
            throw new Exception(e.Message);
        }
    }