Beispiel #1
0
    //[MenuItem("Hugula/project  StandaloneWindows ", false, 16)]
    static void BuildForWindows()
    {
        string path = "../../release/pc/";

        ExportResources.DirectoryDelete(path);
        ExportResources.CheckDirectory(path);
        WriteAppVerion();
        path = path + "hugula.exe";
        BuildPipeline.BuildPlayer(GetBuildScenes(), path, BuildTarget.StandaloneWindows, BuildOptions.None);
    }
Beispiel #2
0
    //  [MenuItem("Hugula/Android publish ", false, 16)]
    static void BuildForAndroid()
    {
        string path = "../../release/android/";

        path = Path.GetFullPath(path);
        ExportResources.CheckDirectory(path);
        path = path + string.Format("hugula{0}.apk", System.DateTime.Now.ToString("MM-dd-hh-mm")); //

        BuildPipeline.BuildPlayer(GetBuildScenes(), path, BuildTarget.Android, BuildOptions.None);
    }
Beispiel #3
0
    //	[MenuItem("Hugula/IOS Publish  ", false, 16)]
    static void BuildForIOS()
    {
        CUtils.DebugCastTime("Time BuildForIOS Begin");
        string path = "../../release/ios";

        path = Path.GetFullPath(path);
        ExportResources.DirectoryDelete(path);
        ExportResources.CheckDirectory(path);
        BuildPipeline.BuildPlayer(GetBuildScenes(), path, BuildTarget.iOS, BuildOptions.None);
        CUtils.DebugCastTime("Time BuildForIOS End");
    }
Beispiel #4
0
    /// <summary>
    /// Creates the streaming crc list.
    /// </summary>
    /// <param name="sb">Sb.</param>
    public static uint CreateStreamingCrcList(StringBuilder sb, string outPath = null)
    {
        var    crc32filename = CUtils.GetAssetName(Common.CRC32_FILELIST_NAME);
        string tmpPath       = BuildScript.GetAssetTmpPath();// Path.Combine(Application.dataPath, BuildScript.TmpPath);

        ExportResources.CheckDirectory(tmpPath);
        string assetPath = "Assets/" + BuildScript.TmpPath + crc32filename + ".txt";

        EditorUtility.DisplayProgressBar("Generate streaming crc file list", "write file to " + assetPath, 0.99f);

        string outTmpPath = Path.Combine(tmpPath, crc32filename + ".txt");

        using (StreamWriter sr = new StreamWriter(outTmpPath, false))
        {
            sr.Write(sb.ToString());
        }
        //
        //打包到streaming path
        AssetDatabase.Refresh();
        string crc32outfilename = CUtils.GetRightFileName(Common.CRC32_FILELIST_NAME);

        Debug.Log("write to path=" + outPath);
        Debug.Log(sb.ToString());
        //读取crc
        string abPath = string.Empty;

        if (string.IsNullOrEmpty(outPath))
        {
            abPath = Path.Combine(CUtils.realStreamingAssetsPath, crc32outfilename);
        }
        else
        {
            abPath = Path.Combine(outPath, crc32outfilename);
        }

        BuildScript.BuildABs(new string[] { assetPath }, outPath, crc32outfilename, BuildAssetBundleOptions.DeterministicAssetBundle);

        CrcCheck.Clear();

        uint fileCrc = CrcCheck.GetLocalFileCrc(abPath);

        EditorUtility.ClearProgressBar();
        Debug.Log("Crc file list assetbunle build complate! " + fileCrc.ToString() + abPath);
        if (!string.IsNullOrEmpty(outPath))
        {
            string   newName = Path.Combine(outPath, CUtils.InsertAssetBundleName(crc32outfilename, "_" + fileCrc.ToString()));
            FileInfo finfo   = new FileInfo(abPath);
            finfo.MoveTo(newName);
            Debug.Log(" change name to " + newName);
        }
        return(fileCrc);
    }
Beispiel #5
0
    // [MenuItem("Hugula/IOS Publish  ", false, 16)]
    static void BuildForIOS()
    {
        CUtils.DebugCastTime("Time BuildForIOS Begin");

        string path = "../../release/ios";

        path = Path.GetFullPath(path);
        IOSSettings();
        ExportResources.DirectoryDelete(path);
        ExportResources.CheckDirectory(path);
        if (setting.ToLower().Contains("development"))
        {
            GenericBuild(GetBuildScenes(), path, BuildTarget.iOS, BuildOptions.Development);
        }
        else
        {
            GenericBuild(GetBuildScenes(), path, BuildTarget.iOS, BuildOptions.None);
        }
        CUtils.DebugCastTime("Time BuildForIOS End");
    }
Beispiel #6
0
    // [MenuItem("Hugula/Android Project publish ", false, 16)]
    static void BuildForAndroidProject()
    {
        string path = "../../release/android";

        path = Path.GetFullPath(path);
        exportingAndroidProject = true;
        AndroidSettings("mono");
        ExportResources.DirectoryDelete(path);
        ExportResources.CheckDirectory(path);
        if (setting.ToLower().Contains("development"))
        {
            GenericBuild(GetBuildScenes(), path, BuildTarget.Android, BuildOptions.Development | BuildOptions.AcceptExternalModificationsToPlayer);
        }
        else
        {
            GenericBuild(GetBuildScenes(), path, BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer);
        }

        CUtils.DebugCastTime("Time BuildForAndroidProject End");
    }
Beispiel #7
0
    // [MenuItem("Hugula/Android IL2CPP Project publish ", false, 16)]
    static void BuildForAndroidProjectIL2CPP()
    {
        string path = "../../release/android_il2cpp";

        path = Path.GetFullPath(path);
        exportingAndroidProject = true;
        AndroidSettings();
        ExportResources.DirectoryDelete(path);
        ExportResources.CheckDirectory(path);
        PlayerSettings.SetPropertyInt("ScriptingBackend", (int)ScriptingImplementation.IL2CPP, BuildTargetGroup.Android);
        if (setting.ToLower().Contains("development"))
        {
            GenericBuild(GetBuildScenes(), path, BuildTarget.Android, BuildOptions.Development | BuildOptions.AcceptExternalModificationsToPlayer);
        }
        else
        {
            GenericBuild(GetBuildScenes(), path, BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer);
        }
        PlayerSettings.SetPropertyInt("ScriptingBackend", (int)ScriptingImplementation.Mono2x, BuildTargetGroup.Android);
        CUtils.DebugCastTime("Time BuildForAndroidProjectIL2CPP End");
    }
Beispiel #8
0
    static void WriteShell()
    {
        string path = Path.GetFullPath("shell");

        ExportResources.DirectoryDelete(path);
        ExportResources.CheckDirectory(path);
        string        shellPath   = Path.Combine(path, "ftp_release_shell.sh");
        StringBuilder ftpTampleta = new StringBuilder();

        ftpTampleta.Append("function foo()\n{\nlocal r\nlocal a\nr=\"$@\"\nwhile [[ \"$r\" != \"$a\" ]] ; do\na=${r%%/*}\necho \"mkdir $a\"\necho \"cd $a\"\nr=${r#*/}\ndone\n}");
        ftpTampleta.Append("\nfunction upload_ftp()\n{\necho \"current folder \"$1\necho \"upload to \"$FTP_ROOT$2\nftp -niv <<- EOF\nopen $FTP_IP\nuser $FTP_USER $FTP_PWD\nlcd $1\n$(foo \"$FTP_ROOT$2\")\ncd $FTP_ROOT$2\nbin\nhash\npwd\nprompt off\nmput *.*\nclose\nbye\nEOF\n}");
        var codeVersion = "";

        if (Hugula.HugulaSetting.instance.appendCrcToFile)
        {
            codeVersion = Hugula.CodeVersion.CODE_VERSION.ToString();
        }
        else
        {
            codeVersion = Hugula.CodeVersion.APP_NUMBER.ToString();         //文件crc 不变路径需要改变
        }
        string        firstPackagePath = SplitPackage.UpdateOutVersionPath; // release/android/v9000
        string        ftpToPath        = CUtils.platform + "/v" + codeVersion;
        StringBuilder content1         = new StringBuilder();

        content1.AppendFormat("\nupload_ftp {0} {1}", firstPackagePath, ftpToPath);                                                                   //eg release/android/v9000 to android/v9001
        content1.AppendFormat("\nupload_ftp {0} {1}", firstPackagePath, string.Format("{0}/v{1}", CUtils.platform, Hugula.CodeVersion.CODE_VERSION)); //eg release/android/v9000 to android/v9000
        content1.AppendFormat("\nupload_ftp {0} {1}", Path.Combine(firstPackagePath, "res"), Path.Combine(ftpToPath, "res"));                         //eg release/android/v9000/res to android/v9001/res
        content1.AppendFormat("\nupload_ftp {0} {1}", Path.Combine(firstPackagePath, "res/battle"), Path.Combine(ftpToPath, "res/battle"));           //eg release/android/v9000/res to android/v9001/res

        using (StreamWriter sw = new StreamWriter(shellPath, false, new UTF8Encoding(false)))
        {
            sw.Write(ftpTampleta.ToString());
            sw.Write(content1.ToString());
        }
        Debug.Log("Create shell success " + shellPath);

        string ftpVerPath = Path.Combine(path, "ftp_dev_shell.sh");

        firstPackagePath = SplitPackage.UpdateOutVersionDevelopPath;
        content1         = new StringBuilder();
        content1.AppendFormat("\nupload_ftp {0} {1}", firstPackagePath, ftpToPath);                                                                   //eg dev/android/v9000 to android/v9001
        content1.AppendFormat("\nupload_ftp {0} {1}", firstPackagePath, string.Format("{0}/v{1}", CUtils.platform, Hugula.CodeVersion.CODE_VERSION)); //eg dev/android/v9000 to android/v9000

        using (StreamWriter sw = new StreamWriter(ftpVerPath, false, new UTF8Encoding(false)))
        {
            sw.Write(ftpTampleta.ToString());
            sw.Write(content1.ToString());
        }
        Debug.Log("Create shell success " + ftpVerPath);

        //environment_shell.sh
        string environmentPath = Path.Combine(path, "environment_shell.sh");

        using (StreamWriter sw = new StreamWriter(environmentPath, false, new UTF8Encoding(false)))
        {
            sw.Write(environmentVariable.ToString());
        }

        environmentVariable = new StringBuilder();
        Debug.Log("Create shell success " + environmentPath);
    }
Beispiel #9
0
    public static void GenerateAssetBundlesMd5Mapping(string[] allAssets)
    {
        string info = "Generate AssetBundles Md5Mapping ";

        EditorUtility.DisplayProgressBar("GenerateAssetBundlesMd5Mapping", info, 0);
        AssetImporter import  = null;
        float         i       = 0;
        float         allLen  = allAssets.Length;
        string        name    = "";
        string        nameMd5 = "";
        StringBuilder sb      = new StringBuilder();

        sb.AppendLine("return {");
        foreach (string path in allAssets)
        {
            import = AssetImporter.GetAtPath(path);
            if (import != null && string.IsNullOrEmpty(import.assetBundleName) == false)
            {
                Object s = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
                name = s.name.ToLower();

                string line = string.Empty;
                if (string.IsNullOrEmpty(import.assetBundleVariant))
                {
                    line = "[\"" + import.assetBundleName + "\"] = { name = \"" + name + "\", path = \"" + path + "\"},";
                }
                else
                {
                    line = "[\"" + import.assetBundleName + "." + import.assetBundleVariant + "\"] = { name = \"" + name + "\", path = \"" + path + "\"},";
                }

                sb.AppendLine(line);
                if (name.Contains(" "))
                {
                    Debug.LogWarning(name + " contains space");
                }
            }
            else
            {
                //Debug.LogWarning(path + " import not exist");
            }
            EditorUtility.DisplayProgressBar("Generate AssetBundles Md5Mapping", info + "=>" + i.ToString() + "/" + allLen.ToString(), i / allLen);

            i++;
        }

        string[] spceil = new string[] { Common.LUA_ASSETBUNDLE_FILENAME, CUtils.platform, Common.CONFIG_CSV_NAME, Common.CRC32_FILELIST_NAME, Common.CRC32_VER_FILENAME };
        foreach (string p in spceil)
        {
            name    = CUtils.GetAssetBundleName(p);
            nameMd5 = CUtils.GetRightFileName(name);
            string line = "[\"" + nameMd5 + "\"] ={ name = \"" + name + "\", path = \"" + p + "\" },";
            sb.AppendLine(line);
        }

        sb.AppendLine("}");
        string tmpPath = Path.Combine(Application.dataPath, TmpPath);

        ExportResources.CheckDirectory(tmpPath);
        EditorUtility.DisplayProgressBar("Generate AssetBundles Md5Mapping", "write file to Assets/" + TmpPath + "Md5Mapping.txt", 0.99f);

        string outPath = Path.Combine(tmpPath, "md5mapping.txt");

        Debug.Log("write to path=" + outPath);
        using (StreamWriter sr = new StreamWriter(outPath, false))
        {
            sr.Write(sb.ToString());
        }

        EditorUtility.ClearProgressBar();
        Debug.Log(info + " Complete! Assets/" + TmpPath + "md5mapping.txt");
    }
Beispiel #10
0
    public static void GenerateAssetBundlesUpdateFile(string[] allBundles)
    {
        string title = "Generate Update File ";
        string info  = "Compute crc32";

        EditorUtility.DisplayProgressBar(title, info, 0.1f);

        #region 读取首包
        CrcCheck.Clear();
        bool          firstExists = false;
        DirectoryInfo firstDir    = new DirectoryInfo(Application.dataPath);
        string        firstPath   = Path.Combine(firstDir.Parent.Parent.FullName, Common.FirstOutPath);
        string        readPath    = Path.Combine(firstPath, CUtils.GetAssetPath(""));
        readPath = Path.Combine(readPath, CUtils.GetRightFileName(Common.CRC32_FILELIST_NAME));
        Debug.Log(readPath);

        WWW abload = new WWW("file://" + readPath);
        if (string.IsNullOrEmpty(abload.error) && abload.assetBundle != null)
        {
            var       ab = abload.assetBundle;
            TextAsset ta = ab.LoadAllAssets <TextAsset>()[0];
            //ta.text
            Debug.Log(ta);
            string   context = ta.text;
            string[] split   = context.Split('\n');
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\[""(.+)""\]\s+=\s+(\d+)");
            float j = 1;
            float l = split.Length;
            foreach (var line in split)
            {
                System.Text.RegularExpressions.Match match = regex.Match(line);
                if (match.Success)
                {
                    //Debug.Log(match.Groups[1].Value + " " + match.Groups[2].Value);
                    CrcCheck.Add(match.Groups[1].Value, System.Convert.ToUInt32(match.Groups[2].Value));
                }
                //Debug.Log(line);
                EditorUtility.DisplayProgressBar(title, "read first crc => " + j.ToString() + "/" + l.ToString(), j / l);
                j++;
            }
            ab.Unload(true);
            firstExists = true;
        }
        else
        {
            Debug.LogWarning(abload.error + "no frist packeage in " + readPath);
        }
        abload.Dispose();
        #endregion

        #region 生成校验列表
        Dictionary <string, uint> updateList = new Dictionary <string, uint>();
        StringBuilder             sb         = new StringBuilder();
        sb.AppendLine("return {");

        var   selected = string.Empty;
        float i        = 0;
        float allLen   = allBundles.Length;

        //忽略列表
        Dictionary <string, bool> ignore = new Dictionary <string, bool>();
        ignore.Add(CUtils.GetRightFileName(Common.CRC32_FILELIST_NAME), true);
        ignore.Add(CUtils.GetRightFileName(Common.CRC32_VER_FILENAME), true);

        foreach (var str in allBundles)
        {
            string url    = Path.Combine(CUtils.GetRealStreamingAssetsPath(), str);
            uint   outCrc = 0;
            Debug.Log(str);
            string abName = str.Replace("\\", "/");
            string key    = CUtils.GetAssetBundleName(abName);
            if (!ignore.ContainsKey(key) && CrcCheck.CheckLocalFileWeakCrc(url, out outCrc) == false) //如果不一致需要更新
            {
                updateList.Add(abName, outCrc);                                                       //记录导出记录
                sb.AppendLine("[\"" + key + "\"] = " + outCrc + ",");
            }
            EditorUtility.DisplayProgressBar(title, info + "=>" + i.ToString() + "/" + allLen.ToString(), i / allLen);
            i++;
        }
        sb.AppendLine("}");
        //Debug.Log (sb.ToString ());
        CrcCheck.Clear();

        //输出到临时目录
        var    crc32filename = CUtils.GetAssetName(Common.CRC32_FILELIST_NAME);
        string tmpPath       = Path.Combine(Application.dataPath, TmpPath);
        ExportResources.CheckDirectory(tmpPath);
        string assetPath = "Assets/" + TmpPath + crc32filename + ".txt";
        EditorUtility.DisplayProgressBar("Generate file list", "write file to " + assetPath, 0.99f);

        string outPath = Path.Combine(tmpPath, crc32filename + ".txt");
        Debug.Log("write to path=" + outPath);
        using (StreamWriter sr = new StreamWriter(outPath, false))
        {
            sr.Write(sb.ToString());
        }
        //
        //打包到streaming path
        AssetDatabase.Refresh();
        string crc32outfilename = CUtils.GetRightFileName(Common.CRC32_FILELIST_NAME); //(fileCrc32ListName + ".u3d");
        BuildScript.BuildABs(new string[] { assetPath }, null, crc32outfilename, BuildAssetBundleOptions.DeterministicAssetBundle);
        string topath = Path.Combine(GetOutPutPath(), crc32outfilename);
        Debug.Log(info + " assetbunle build complate! " + topath);

        #endregion

        #region 生成版本号
        //生成版本号码
        string crc32Path = "file://" + Path.Combine(CUtils.GetRealStreamingAssetsPath(), CUtils.GetRightFileName(Common.CRC32_FILELIST_NAME)); //CUtils.GetAssetFullPath (fileCrc32ListName+".u3d");
        WWW    loaderVer = new WWW(crc32Path);
        if (!string.IsNullOrEmpty(loaderVer.error))
        {
            Debug.LogError(loaderVer.error);
            return;
        }
        uint crcVer = Crc32.Compute(loaderVer.bytes);
        loaderVer.Dispose();

        tmpPath = CUtils.GetRealStreamingAssetsPath();//Path.Combine (Application.streamingAssetsPath, CUtils.GetAssetPath(""));
        outPath = Path.Combine(tmpPath, CUtils.GetRightFileName(Common.CRC32_VER_FILENAME));
        Debug.Log("verion to path=" + outPath);
        //json 化version{ code,crc32,version}
        StringBuilder verJson = new StringBuilder();
        verJson.Append("{");
        verJson.Append(@"""code"":" + CodeVersion.CODE_VERSION + ",");
        verJson.Append(@"""crc32"":" + crcVer.ToString() + ",");
        verJson.Append(@"""time"":" + CUtils.ConvertDateTimeInt(System.DateTime.Now) + "");
        verJson.Append("}");

        using (StreamWriter sr = new StreamWriter(outPath, false))
        {
            sr.Write(verJson.ToString());
        }

        Debug.Log(info + " Complete! ver=" + crcVer.ToString() + " path " + outPath);
        BuildScript.BuildAssetBundles();

        #endregion

        #region copy更新文件导出
        if (updateList.Count > 0)
        {
            info = "copy updated file ";
            string        updateOutPath = Path.Combine(firstPath, CUtils.GetAssetPath("") + System.DateTime.Now.ToString("_yyyy-MM-dd_HH-mm"));
            DirectoryInfo outDic        = new DirectoryInfo(updateOutPath);
            if (outDic.Exists)
            {
                outDic.Delete();
            }
            outDic.Create();

            if (!firstExists)
            {
                updateList.Clear();               //如果没有首包,只导出校验文件。
            }
            updateList.Add(CUtils.GetRightFileName(Common.CRC32_VER_FILENAME), 0);
            updateList.Add(CUtils.GetRightFileName(Common.CRC32_FILELIST_NAME), crcVer);

            string sourcePath;
            string outfilePath;
            i      = 1;
            allLen = updateList.Count;
            string key = "";
            foreach (var k in updateList)
            {
                key        = CUtils.GetAssetBundleName(k.Key);
                sourcePath = Path.Combine(CUtils.GetRealStreamingAssetsPath(), k.Key);
                if (k.Value != 0)
                {
                    if (key.Equals(CUtils.platformFloder))
                    {
                        key = key + "_" + k.Value.ToString() + "." + Common.ASSETBUNDLE_SUFFIX;
                    }
                    else
                    {
                        key = CUtils.InsertAssetBundleName(key, "_" + k.Value.ToString());//
                    }
                }
                outfilePath = Path.Combine(updateOutPath, key);
                FileHelper.CheckCreateFilePathDirectory(outfilePath);
                File.Copy(sourcePath, outfilePath, true);// source code copy
                EditorUtility.DisplayProgressBar(title, info + "=>" + i.ToString() + "/" + allLen.ToString(), i / allLen);
                i++;
            }
            Debug.Log(" copy  file complete!");
        }
        #endregion

        EditorUtility.ClearProgressBar();
    }