예제 #1
0
    public static void BuildiOSPlayer(string profile, bool debug, BuildOptions options)
    {
        BuildSettings.Options = options;
        var path = GetBuildPath();

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        string[] originalScenes = BuildSettings.GetScenesFromEditorSettings();


        string[] buildScenes = originalScenes;

        if (BuildSettings.IsDevelopmentBuild)
        {
            if (BuildSettings.DevBundleMode == EB.Assets.DevBundleType.BundleServer)                    // only the basic levels are built in to the player, others are separate bundles for smaller packages while debugging
            {
                List <string> filteredScenes = new List <string>();
                foreach (string scene in originalScenes)
                {
                    string lowerScene = scene.ToLower();
                    foreach (string playerBuilt in BuildSettings.PlayerBuiltInScenes)
                    {
                        if (lowerScene.Contains(playerBuilt))
                        {
                            filteredScenes.Add(scene);
                            Debug.Log("Player Building scene: " + scene);
                            break;
                        }
                    }
                }
                buildScenes = filteredScenes.ToArray();
            }
        }
        else
        {
            List <string> tmp = new List <string>(originalScenes);
//NOTE: including the selector for now.
//			if (tmp[0].Contains("selector"))
//			{
//				Debug.Log("REMOVING SELECTOR SCENE");
//				tmp.RemoveAt(0);
//
//			}
            buildScenes = tmp.ToArray();
        }

        // copy profiles
        CopyProvisioningProfile(profile);

        Debug.Log("Building player with...");
        foreach (string s in buildScenes)
        {
            Debug.Log("\t" + s);
        }

        bool movedBundles = false;

        //bool isP4ConnectEnabled = P4Connect.Config.PerforceEnabled;
        try {
            if (BuildSettings.DevBundleMode != EB.Assets.DevBundleType.NoBundles)
            {
                Debug.Log("Moving Resources/Bundles out of Assets/ to build iOS Player ");
                movedBundles = true;

                //P4Connect.Config.PerforceEnabled = false;
                BuildUtils.HideBundlesDirs();
                //EditorUtility.UnloadUnusedAssets();

                if (!UnityEditor.VersionControl.Provider.isActive)
                {
                    // only do this on the build server (no UNITY P4 version control set up) because it will check out every file we just moved for delete (works fine with the 3rd party plugin)
                    Debug.Log("Refreshing Asset Database to remove references in Assets/Resources/Bundles");
                    AssetDatabase.Refresh();
                }
            }
            Debug.Log("***** BuildPipeline.BuildPlayer");
            BuildPipeline.BuildPlayer(buildScenes, path, BuildTarget.iOS, options);
            Debug.Log("***** BuildPipeline.BuildPlayer DONE");
        }
        finally
        {
            if (movedBundles)
            {
                Debug.Log("Moving Resources/Bundles back to Assets/ after building iOS Player");
                BuildUtils.UnHideBundlesDirs();
                //P4Connect.Config.PerforceEnabled = isP4ConnectEnabled;
                //EB.Perforce.Perforce.P4RevertUnchanged();
            }
        }
    }
예제 #2
0
    public static void BuildPlayer(string apkPath, BuildOptions options)
    {
        BuildSettings.Options = options;
#if USE_XINKUAISDK
        PlayerSettings.Android.keystorePass = "******";
        PlayerSettings.Android.keyaliasName = "xinyou";
        PlayerSettings.Android.keyaliasPass = "******";
        PlayerSettings.Android.keystoreName = "Assets/Editor/Android/key.keystore";
#else
        PlayerSettings.Android.keystorePass = "******";
        PlayerSettings.Android.keyaliasName = "ebg";
        PlayerSettings.Android.keyaliasPass = "******";
        PlayerSettings.Android.keystoreName = "Assets/Editor/Android/android.keystore";
#endif
        EB.Debug.Log("Building to " + apkPath);

        string[] originalScenes = BuildSettings.GetScenesFromEditorSettings();
        string[] buildScenes    = originalScenes;

        if (BuildSettings.IsDevelopmentBuild)
        {
            if (BuildSettings.DevBundleMode == EB.Assets.DevBundleType.BundleServer)                    // only the basic levels are built in to the player, others are separate bundles for smaller packages while debugging
            {
                List <string> filteredScenes = new List <string>();
                foreach (string scene in originalScenes)
                {
                    string lowerScene = scene.ToLower();
                    foreach (string playerBuilt in BuildSettings.PlayerBuiltInScenes)
                    {
                        if (lowerScene.Contains(playerBuilt))
                        {
                            filteredScenes.Add(scene);
                            Debug.Log("Player Building scene: " + scene);
                            break;
                        }
                    }
                }
                buildScenes = filteredScenes.ToArray();
            }
        }

        try {
            if (BuildSettings.DevBundleMode != EB.Assets.DevBundleType.NoBundles)
            {
                Debug.Log("Moving Resources/Bundles out of Assets/ to build Player");
                BuildUtils.HideBundlesDirs();
            }

            BuildPipeline.BuildPlayer(buildScenes, apkPath, BuildTarget.Android, options);
        } finally {
            if (BuildSettings.DevBundleMode != EB.Assets.DevBundleType.NoBundles)
            {
                Debug.Log("Returning Resources/Bundles to Assets/ after building Player");
                BuildUtils.UnHideBundlesDirs();
            }
        }

        if (!File.Exists(apkPath))
        {
            throw new System.Exception("Failed to build apk!");
        }
    }