コード例 #1
0
    public static void CopyLuaFilesToRes()
    {
        string path = Application.dataPath + "/Resources/Lua";

        if (Directory.Exists(path))
        {
            Directory.Delete(path, true);
        }
        string destDir = Application.dataPath + "/Resources" + "/Lua";

        AssetBundleBuildScript.CopyLuaBytesFiles(LuaConst.luaDir, destDir);
        AssetBundleBuildScript.CopyLuaBytesFiles(LuaConst.toluaDir, destDir);
        AssetDatabase.Refresh();
        Debug.Log("Copy lua files over");
    }
コード例 #2
0
    void DrawBuild()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginVertical();
        GUILayout.Space(10);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("打包标志:", GUILayout.Width(80));
        if (EditorGUILayout.ToggleLeft("Md5", ABEditor.ABVersionTools.isUseMd5))
        {
            ABEditor.ABVersionTools.isUseMd5  = true;
            ABEditor.ABVersionTools.isUseHash = false;
        }

        if (EditorGUILayout.ToggleLeft("Hash", ABEditor.ABVersionTools.isUseHash))
        {
            ABEditor.ABVersionTools.isUseMd5  = false;
            ABEditor.ABVersionTools.isUseHash = true;
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("独立版本", GUILayout.Width(80), GUILayout.Height(35)))
        {
            AssetDatabase.Refresh();
#if UNITY_ANDROID || UNITY_IOS || UNITY_IPHONE
            GameConfigProject.instance.developmentMode = false;
#endif
            if (!EditorApplication.isCompiling)
            {
                if (mBuildAssetBundle) //是否打包资源
                {
                    if (AssetBundleBuildScript.BuildAssetBundles(true))
                    {
                        mEditorAssetBundleVersion.GenerationStandaloneVersion();
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("提示", "打包错误,停止迭代版本", "确定");
                    }
                }

                if (mBuild)
                {
                    string lastProductName = PlayerSettings.productName;
                    if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
                    {
                        EditorUserBuildSettings.exportAsGoogleAndroidProject = mExportProject;
                    }
                    else
                    {
                        EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
                        if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows ||
                            EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64)
                        {
                            PlayerSettings.productName = Application.identifier;
                        }
                    }

                    RemoveGameRoot(); //移除GameRoot
                    if (mEditorGameBuildConfigurations.buildAppAutoIncreaseVersion)
                    {
                        PlayerSettings.bundleVersion = AutoIncreaseAppVersion();
                    }

                    mEditorGameBuildConfigurations.SetAndroidKeystore();
                    BeginBuild();
                    mEditorGameBuildConfigurations.ResetKeystore();
                    AddGameRoot();
                    PlayerSettings.productName = lastProductName;
                    return;
                }
            }
            else
            {
                EditorUtility.DisplayDialog("提示", "正在编译不能打包!", "确定");
            }
        }

        EditorGUILayout.BeginVertical();
        mBuild = GUILayout.Toggle(mBuild, "Build");
        if (mBuild)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(18);
            EditorGUILayout.BeginVertical();
            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS)
            {
                mExportProject = true;
                mBuildApp      = GUILayout.Toggle(mBuildApp, "自动生成ipa");
                mAutoRunPlayer = GUILayout.Toggle(mAutoRunPlayer, "AutoRunPlayer");
                if (mAutoRunPlayer)
                {
                    mBuildApp = false;
                }

                mAutoRunPlayer = !mBuildApp;
            }
            else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
            {
                mBuildApp = GUILayout.Toggle(mBuildApp, "生成App");
                if (GUI.changed)
                {
                    mExportProject = !mBuildApp;
                }

                mExportProject = GUILayout.Toggle(mExportProject, "导出工程");
                if (GUI.changed)
                {
                    mBuildApp = !mExportProject;
                }
            }
            else
            {
                mBuildApp      = GUILayout.Toggle(mBuildApp, "自动生成App");
                mExportProject = false;
            }


            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS ||
                EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
            {
                mAppAutoPublishToFir = GUILayout.Toggle(mAppAutoPublishToFir, "app自动上传fir");

                if (mAppAutoPublishToFir)
                {
                    if (GUI.changed)
                    {
                        mPushMsgToDingDingRobot = true;
                    }

                    EditorGUILayout.LabelField("Fir日志内容:");
                    mFirLog = EditorGUILayout.TextArea(mFirLog, GUILayout.Height(80), GUILayout.Width(250));
                }
                else
                {
                    mPushMsgToDingDingRobot = false;
                }
            }
            else
            {
                mAppAutoPublishToFir    = false;
                mPushMsgToDingDingRobot = false;
            }

            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
            {
                mAppAutoPublishToBruceXuFir = GUILayout.Toggle(mAppAutoPublishToBruceXuFir, "app自动上传Bruce.Xu的fir");
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();
        mBuildAssetBundle = GUILayout.Toggle(mBuildAssetBundle, "资源重构");
        EditorGUILayout.EndVertical();

        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("生成补丁", GUILayout.Width(80), GUILayout.Height(35)))
        {
            AssetDatabase.Refresh();
            if (!EditorApplication.isCompiling)
            {
                mEditorAssetBundleVersion.versionUploadFileToServerSuccessCallback = (x, y) =>
                {
                    if (mAssetVersionUploadServerPushMsgToDingDingRobot)
                    {
                        AssetVersionUploadToServerHint(x, y);
                    }
                };
                if (AssetBundleBuildScript.BuildAssetBundles(true))
                {
                    mEditorGameBuildConfigurations.OpenAllGameBuildResBools();
                    if (mEditorAssetBundleVersion.GenerationIterativeVersion() != null)
                    {
                        if (mAutoUploadServer)
                        {
                            if (mAutoUploadServerAll)
                            {
                                string host;
                                if (mEditorGameBuildConfigurations.resourcesIpDatas.TryGetValue(
                                        (GameConfigNet.IPAdress)hosInt1, out host))
                                {
                                    mEditorGameBuildConfigurations.resourcesUploadServerHost = host;
                                }

                                mEditorAssetBundleVersion.UploadFileToServer(true);
                                mEditorAssetBundleVersion.versionUploadFileToServerSuccessCallback = (x, y) =>
                                {
                                    if (mEditorGameBuildConfigurations.resourcesIpDatas.TryGetValue(
                                            (GameConfigNet.IPAdress)hosInt2, out host))
                                    {
                                        mEditorGameBuildConfigurations.resourcesUploadServerHost = host;
                                        mEditorAssetBundleVersion.UploadFileToServer(false);
                                        mEditorAssetBundleVersion.versionUploadFileToServerSuccessCallback = (m, n) =>
                                        {
                                            if (mAssetVersionUploadServerPushMsgToDingDingRobot)
                                            {
                                                AssetVersionUploadToServerHint(x, y);
                                            }
                                        };
                                    }
                                };
                            }
                            else
                            {
                                mEditorAssetBundleVersion.UploadFileToServer(true);
                            }
                        }
                    }

                    mEditorGameBuildConfigurations.ResetGameBuildResBools();
                }
                else
                {
                    Debug.LogError("打包错误,停止迭代版本");
                }
            }
            else
            {
                EditorUtility.DisplayDialog("提示", "正在编译不能打包!", "确定");
            }
        }

        EditorGUILayout.BeginVertical();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical(GUILayout.Width(80));
        mAutoUploadServer = GUILayout.Toggle(mAutoUploadServer, "上传资源");
        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();
        EditorGUILayout.BeginHorizontal(GUILayout.Width(180));
        mAutoUploadServerAll = GUILayout.Toggle(mAutoUploadServerAll, "同时上传正式服测试服");
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical(GUILayout.Width(120));
        if (mAutoUploadServerAll)
        {
            if (mEditorGameBuildConfigurations.mConfig.net.ipAdressTypeName.Length < 2)
            {
                hosInt1 = 0;
                hosInt2 = 0;
            }

            EditorGUILayout.BeginHorizontal();
            hosInt1 = EditorGUILayout.Popup(hosInt1, mEditorGameBuildConfigurations.mConfig.net.ipAdressTypeName,
                                            GUILayout.Width(120)); //.resourcesIpDatas.Keys.ToDynList().ToArray());
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            hosInt2 = EditorGUILayout.Popup(hosInt2, mEditorGameBuildConfigurations.mConfig.net.ipAdressTypeName,
                                            GUILayout.Width(120));
            EditorGUILayout.EndHorizontal();

            if (GUI.changed)
            {
                string host;
                if (mEditorGameBuildConfigurations.resourcesIpDatas.TryGetValue((GameConfigNet.IPAdress)hosInt1,
                                                                                out host))
                {
                    host1 = host;
                }

                if (mEditorGameBuildConfigurations.resourcesIpDatas.TryGetValue((GameConfigNet.IPAdress)hosInt2,
                                                                                out host))
                {
                    host2 = host;
                }

                // Debug.Log("GUI.changed----------------------------");
                // Debug.Log("host1: "+host1);
                // Debug.Log("host2: "+host2);
            }
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        bool last = mAssetVersionUploadServerPushMsgToDingDingRobot;
        mAssetVersionUploadServerPushMsgToDingDingRobot = false;
        mEditorAssetBundleVersion.assetVersionUploadServerPushMsgToDingDingRobot =
            mAssetVersionUploadServerPushMsgToDingDingRobot;
        if (mAssetVersionUploadServerPushMsgToDingDingRobot)
        {
            if (last != mAssetVersionUploadServerPushMsgToDingDingRobot)
            {
                mEditorAssetBundleVersion.versionUploadFileToServerSuccessCallback = (x, y) =>
                {
                    if (mAssetVersionUploadServerPushMsgToDingDingRobot)
                    {
                        AssetVersionUploadToServerHint(x, y);
                    }
                };
            }

            EditorGUILayout.LabelField("补丁内容:");
            mAssetVersionUploadServerLog = EditorGUILayout.TextArea(mAssetVersionUploadServerLog, GUILayout.Height(80),
                                                                    GUILayout.Width(250));
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();


        if (GUILayout.Button("测试", GUILayout.Width(80), GUILayout.Height(20)))
        {
            if (EditorApplication.isCompiling)
            {
                EditorUtility.DisplayDialog("提示", "正在编译不能打包!", "确定");
            }

            var crc = AssetDatabase.LoadAssetAtPath <AssetBundleCRCScriptableObject>("Assets/asset_bundle_crc.asset");
            Debug.Log(crc.crcData.Count);

//            ReadyDingDingRobot();
            //AutoPublishToFir_Windows();
            // AutoPublishToFir("/Users/dred/Workbench/Apps/CrazyCowBoy(v0.6.10)(2017-0423-1444).apk");
            // AutoBuildIpa("/Users/dred/Workbench/Apps/XcodeProject_BullFight_v1.0.0_2017-0501-0033", "BullFight_v1.0.0_2017-0501-0033", mAppAutoPublishToFir);
            // ProcessStartInfo psi = new ProcessStartInfo();
            // psi.FileName = "/bin/bash";
            // psi.WindowStyle= ProcessWindowStyle.Normal;
            // // psi.FileName = "/usr/local/bin/fir";
            // psi.CreateNoWindow=false;
            // psi.UseShellExecute = false;
            // psi.RedirectStandardOutput = true;
            // string shell = Application.dataPath +"/Editor/open.sh" ;
            // psi.Arguments = shell + " fir publish /Users/dred/Workbench/Apps/CrazyCowBoy_v0.6.9_2017-0422-1810.apk";
            // // psi.Arguments = "fir publish /Users/dred/Workbench/Apps/CrazyCowBoy_v0.6.9_2017-0422-1810.apk";

            // Process p = Process.Start(psi);
            // Thread.Sleep(300);
            // string strOutput = p.StandardOutput.ReadToEnd();
            // p.WaitForExit();

            // UnityEngine.Debug.Log(strOutput);

            // foreach (var content in mFirLog.Split('\n')) {
            //     Debug.Log(content);
            // }
            // ReadyDingDingRobot();
        }

        if (GUILayout.Button("开启git列表", GUILayout.Width(80), GUILayout.Height(20)))
        {
            string ignoreText = FileUtility.ReadAllText(EditorGitConfig.gitIgnorePath);
            ignoreText = ignoreText.Replace(EditorGitConfig.closeAbGit, "");
            for (int i = 0; i < EditorGitConfig.openAbGit.Length; i++)
            {
                ignoreText  = ignoreText.Replace(EditorGitConfig.openAbGit[i], "");
                ignoreText += EditorGitConfig.openAbGit[i];
            }

            //Debug.Log(ignoreText);
            FileUtility.SaveFile(EditorGitConfig.gitIgnorePath, ignoreText);
            EditorUtility.DisplayDialog("提示", "已开启git上传AB包配置!", "确定");
        }

        if (GUILayout.Button("屏蔽git列表", GUILayout.Width(80), GUILayout.Height(20)))
        {
            string ignoreText = FileUtility.ReadAllText(EditorGitConfig.gitIgnorePath);
            ignoreText = ignoreText.Replace(EditorGitConfig.closeAbGit, "");
            for (int i = 0; i < EditorGitConfig.openAbGit.Length; i++)
            {
                Debug.Log("Is contains = " + ignoreText.Contains(EditorGitConfig.openAbGit[i]));
                ignoreText = ignoreText.Replace(EditorGitConfig.openAbGit[i], "");
            }

            ignoreText += EditorGitConfig.closeAbGit;
            //Debug.Log(ignoreText);
            FileUtility.SaveFile(EditorGitConfig.gitIgnorePath, ignoreText);
            EditorUtility.DisplayDialog("提示", "已关闭git上传AB包配置!", "确定");
        }

        mInputNeedGetRealName =
            EditorGUILayout.TextField(mInputNeedGetRealName, GUILayout.Height(40), GUILayout.Width(100));
        if (!string.IsNullOrEmpty(mInputNeedGetRealName))
        {
            string realName = FileUtility.DecryptFilePath(mInputNeedGetRealName.Replace("Assets/StreamingAssets/", ""));
            Debug.Log(realName);
            mInputNeedGetRealName = "";
            EditorUtility.DisplayDialog("真是路径", realName, "确定");
        }


        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }
コード例 #3
0
 static public void BuildGameAssetBundles()
 {
     AssetBundleBuildScript.BuildAssetBundles(false);
     PrintSelectedAbAllAssetsName();
 }