예제 #1
0
    public static void Build()
    {
        //打最新的ab包
        BundleEditor.Build();
        //打包
        string abPath     = Application.dataPath + "/../AssetBundle/" + EditorUserBuildSettings.activeBuildTarget.ToString() + "/";
        string targetPath = AssetBundleManger.Instance.ABLoadpath;

        Copy(abPath, targetPath);//复制ab包到streamasset/AssetBundle
        string savePath = "";

        switch (EditorUserBuildSettings.activeBuildTarget)
        {
        case BuildTarget.Android:
            savePath = m_AndroidPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget +
                       string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now) + ".apk";
            break;

        case BuildTarget.iOS:
            break;

        case BuildTarget.StandaloneWindows:
        case BuildTarget.StandaloneWindows64:
            savePath = m_WindowsPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget +
                       string.Format("_{0:yyyy_MM_dd_HH_mm}/{1}.exe", DateTime.Now, m_AppName);
            break;

        default:
            Debug.Log("当前选择平台不支持自动打包" + EditorUserBuildSettings.activeBuildTarget);
            break;
        }
        BuildPipeline.BuildPlayer(FindEnableEditorScenes(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
        Delete(targetPath);
    }
예제 #2
0
    public static void Build()
    {
        //打ab包
        BundleEditor.Build();
        //生成可执行程序
        string abPath = Application.dataPath + "/../AssetBundle/" + EditorUserBuildSettings.activeBuildTarget.ToString() + "/";

        Copy(abPath, Application.streamingAssetsPath);
        string savePath = "";

        if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
        {
            savePath = m_AndroidPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now) + ".apk";
        }
        else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS)
        {
            savePath = m_IOSPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now);
        }
        else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows || EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64)
        {
            savePath = m_WindowsPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget + string.Format("_{0:yyyy_MM_dd_HH_mm}/{1}.exe", DateTime.Now, m_AppName);
        }

        BuildPipeline.BuildPlayer(FindEnableEditorrScenes(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
        DeleteDir(Application.streamingAssetsPath);
    }
예제 #3
0
    public static void BuildIOS()
    {
        //打ab包
        BundleEditor.Build();
        BuildSetting buildSetting = GetIOSBuildSetting();
        string       suffix       = SetIOSSetting(buildSetting);

        //生成可执行程序
        string abPath = Application.dataPath + "/../AssetBundle/" + EditorUserBuildSettings.activeBuildTarget.ToString() + "/";

        //清空生成的文件夹
        DeleteDir(m_IOSPath);
        Copy(abPath, Application.streamingAssetsPath);
        string name     = m_AppName + "_IOS" + suffix + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now);
        string savePath = m_IOSPath + name;

        BuildPipeline.BuildPlayer(FindEnableEditorrScenes(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
        DeleteDir(Application.streamingAssetsPath);
        WriteBuildName(name);
    }
예제 #4
0
    public static void BuildAndroid()
    {
        //打ab包
        BundleEditor.Build();
        PlayerSettings.Android.keystorePass = "******";
        PlayerSettings.Android.keyaliasPass = "******";
        PlayerSettings.Android.keyaliasName = "android.keystore";
        PlayerSettings.Android.keystoreName = Application.dataPath.Replace("/Assets", "") + "/realfram.keystore";
        BuildSetting buildSetting = GetAndoridBuildSetting();
        string       suffix       = SetAndroidSetting(buildSetting);
        //生成可执行程序
        string abPath = Application.dataPath + "/../AssetBundle/" + EditorUserBuildSettings.activeBuildTarget.ToString() + "/";

        //清空生成的文件夹
        DeleteDir(m_AndroidPath);
        Copy(abPath, Application.streamingAssetsPath);
        string savePath = m_AndroidPath + m_AppName + "_Andorid" + suffix + string.Format("_{0:yyyy_MM_dd_HH_mm}.apk", DateTime.Now);

        BuildPipeline.BuildPlayer(FindEnableEditorrScenes(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
        DeleteDir(Application.streamingAssetsPath);
    }
예제 #5
0
    private void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        md5Path = EditorGUILayout.TextField("ABMD5路径: ", md5Path, GUILayout.Width(350), GUILayout.Height(20));
        if (GUILayout.Button("选择版本ABMD5文件", GUILayout.Width(150), GUILayout.Height(30)))
        {
            m_OpenFileName              = new OpenFileName();
            m_OpenFileName.structSize   = Marshal.SizeOf(m_OpenFileName);
            m_OpenFileName.filter       = "ABMD5文件(*.bytes)\0*.bytes";
            m_OpenFileName.file         = new string(new char[256]);
            m_OpenFileName.maxFile      = m_OpenFileName.file.Length;
            m_OpenFileName.fileTitle    = new string(new char[64]);
            m_OpenFileName.maxFileTitle = m_OpenFileName.fileTitle.Length;
            //默认路径
            m_OpenFileName.initialDir = (Application.dataPath + "/../Version").Replace("/", "\\");
            m_OpenFileName.title      = "打开ABMD5窗口";
            m_OpenFileName.flags      = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008;

            //执行完的回调
            if (LocalDialog.GetSaveFileName(m_OpenFileName))
            {
                Debug.Log(m_OpenFileName.file);
                md5Path = m_OpenFileName.file;
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        hotCount = EditorGUILayout.TextField("热更补丁版本:", hotCount, GUILayout.Width(350), GUILayout.Height(20));
        EditorGUILayout.EndHorizontal();
        if (GUILayout.Button("开始打热更包", GUILayout.Width(100), GUILayout.Height(50)))
        {
            if (!string.IsNullOrEmpty(md5Path) && md5Path.EndsWith(".bytes"))
            {
                BundleEditor.Build(true, md5Path, hotCount);
            }
        }
    }