Beispiel #1
0
//    [MenuItem("Build Target/PreBuidTarget")]
//    static void PerformCopyToBuidTarget()
//    {
//        PreBuildTarget("OPPO", "Android");
//    }
//
//    [MenuItem("Build Target/ClearBuidTarget")]
//    static void ClearBuidTarget()
//    {
//        CleanAndroidBuildTarget();
//    }

    static void BuildTarget(string name, string target)
    {
        string app_name   = "JiangHu" + DateTime.Now.ToString("yyyyMMdd_") + name;
        string target_dir = string.Empty;            // Application.dataPath + "/TargetAndroid";

        string           target_name = string.Empty; // app_name + ".apk";
        BuildTargetGroup targetGroup = BuildTargetGroup.Android;
        BuildTarget      buildTarget = UnityEditor.BuildTarget.Android;

        string applicationPath = Application.dataPath.Replace("/Assets", "");

        if (target == "Android")
        {
            target_dir  = applicationPath + "/TargetAndroid";
            target_name = app_name + ".apk";
            targetGroup = BuildTargetGroup.Android;
        }
        else if (target == "IOS")
        {
            target_dir  = applicationPath + "/TargetIOS";
            target_name = app_name;
            targetGroup = BuildTargetGroup.iPhone;
            buildTarget = UnityEditor.BuildTarget.iPhone;
        }

        //FileInfo buildFile = new FileInfo(target_dir);
        //if (buildFile.Exists)
        //    buildFile.Delete();

        if (File.Exists(target_name))
        {
            File.Delete(target_name);
        }

        if (!Directory.Exists(target_dir))
        {
            Directory.CreateDirectory(target_dir);
        }
        string sourcePath = "";

        switch (name)
        {
        case "UC":
            PlayerSettings.bundleIdentifier = "com.fanhou.jianghu.uc";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_UC");
            sourcePath = UI_PATH_NAME;
            break;

        case "JIUYAO":
            PlayerSettings.bundleIdentifier = "com.fanhou.jianghu.jiuyao";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_JIUYAO");
            break;

        case "XIAOMI":
            PlayerSettings.bundleIdentifier = "Pushcraft.mi";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_XIAOMI");
            sourcePath = MI_PATH_NAME;
            break;

//            case "OPPO":
//                PlayerSettings.bundleIdentifier = "com.fanhou.jianghu.nearme";
//                PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_OPPO");
//                sourcePath=OPPO_PATH_NAME;
//                break;
        case "OPPO_0917":
            PlayerSettings.bundleIdentifier = "com.fanhou.jianghu.nearme.gamecenter";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_OPPO");
            sourcePath = OPPONEW_PATH_NAME;
            break;

        case "TencentTest":
            PlayerSettings.bundleIdentifier = "com.tencent.tmgp.yjws";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_TENCENT; TENCENT_TEST");
            PlayerSettings.keyaliasPass = "******";
            PlayerSettings.keystorePass = "******";
            sourcePath = TENCENT_TEST_PATH;
            break;

        case "TencentRelease":
            PlayerSettings.bundleIdentifier = "com.tencent.tmgp.yjws";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_TENCENT; TENCENT_RELEASE");
            PlayerSettings.keyaliasPass = "******";
            PlayerSettings.keystorePass = "******";
            sourcePath = TENCENT_RELEASE_PATH;
            break;

        default:
            break;
        }

        //string target_folder = EditorUtility.SaveFolderPanel("111", "", "2222");
        string target_fileName = EditorUtility.SaveFilePanel("BuildTarget", target_dir, target_name, "");

        if (string.IsNullOrEmpty(target_fileName))
        {
            return;
        }

        //拷贝相应平台的Plugins/Android到Plugins/Android
        BuildUtils.CopyDirectoryRecursiveIgnoreMeta(Path.Combine(PLATFORM_ANDROID_PATH, sourcePath), PLATFORM_PLUGINS_TARGET);
        AssetDatabase.Refresh();

        //开始Build场景
        GenericBuild(Scenes, target_fileName, buildTarget, BuildOptions.None);

        PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "");

        BuildUtils.PrepareCleanDirectory(PLATFORM_PLUGINS_TARGET);
    }
Beispiel #2
0
    public static void CopyToBuildTarget(string name, string target)
    {
        BuildTargetGroup targetGroup     = BuildTargetGroup.Android;
        BuildTarget      buildTarget     = UnityEditor.BuildTarget.Android;
        string           applicationPath = Application.dataPath.Replace("/Assets", "");

        if (target == "IOS")
        {
            targetGroup = BuildTargetGroup.iPhone;
            buildTarget = UnityEditor.BuildTarget.iPhone;
        }
        string sourcePath = "";

        switch (name)
        {
        case "UC":
            PlayerSettings.bundleIdentifier = "com.fanhou.jianghu.uc";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_UC");
            sourcePath = UI_PATH_NAME;
            break;

        case "JIUYAO":
            PlayerSettings.bundleIdentifier = "com.fanhou.jianghu.jiuyao";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_JIUYAO");
            break;

        case "XIAOMI":
            PlayerSettings.bundleIdentifier = "Pushcraft.mi";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_XIAOMI");
            sourcePath = MI_PATH_NAME;
            break;

//            case "OPPO":
//                PlayerSettings.bundleIdentifier = "com.fanhou.jianghu.nearme";
//                PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_OPPO");
//                sourcePath=OPPO_PATH_NAME;
//                break;
        case "OPPO_0917":
            PlayerSettings.bundleIdentifier = "com.fanhou.jianghu.nearme.gamecenter";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_OPPO");
            sourcePath = OPPONEW_PATH_NAME;
            break;

        case "TencentTest":
            PlayerSettings.bundleIdentifier = "com.tencent.tmgp.yjws";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_TENCENT; TENCENT_TEST");
            PlayerSettings.keyaliasPass = "******";
            PlayerSettings.keystorePass = "******";
            sourcePath = TENCENT_TEST_PATH;
            break;

        case "TencentRelease":
            PlayerSettings.bundleIdentifier = "com.tencent.tmgp.yjws";
            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, "ANDROID_TENCENT; TENCENT_RELEASE");
            PlayerSettings.keyaliasPass = "******";
            PlayerSettings.keystorePass = "******";
            sourcePath = TENCENT_RELEASE_PATH;
            break;

        default:
            break;
        }

        BuildUtils.CopyDirectoryRecursiveIgnoreMeta(Path.Combine(PLATFORM_ANDROID_PATH, sourcePath), PLATFORM_PLUGINS_TARGET);
        AssetDatabase.Refresh();
    }