public void OnPostGenerateGradleAndroidProject(string path)
        {
            if (!PlayInstantBuildConfiguration.IsInstantBuildType())
            {
                return;
            }

            // Update the final merged AndroidManifest.xml prior to the gradle build.
            var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");

            Debug.LogFormat("Updating manifest for Play Instant: {0}", manifestPath);

            Uri uri        = null;
            var instantUrl = PlayInstantBuildConfiguration.InstantUrl;

            if (!string.IsNullOrEmpty(instantUrl))
            {
                uri = new Uri(instantUrl);
            }

            var doc          = XDocument.Load(manifestPath);
            var errorMessage = AndroidManifestHelper.ConvertManifestToInstant(doc, uri);

            if (errorMessage != null)
            {
                PlayInstantBuilder.DisplayBuildError(
                    string.Format("Error updating AndroidManifest.xml: {0}", errorMessage));
                return;
            }

            doc.Save(manifestPath);
        }
예제 #2
0
        private static void ConfigureProject()
        {
            var requiredPolicies = PlayInstantSettingPolicy.GetRequiredPolicies();

            foreach (var policy in requiredPolicies)
            {
                policy.ChangeState();
            }

            PlayInstantBuildConfiguration.SaveConfiguration("", TestScenePaths, "");
            PlayInstantBuildConfiguration.SetInstantBuildType();
            PlayerSettings.applicationIdentifier = BundleIdentifier;
        }
        /// <summary>
        /// Builds an AssetBundle containing scenes at given paths, and stores the AssetBundle at configured path.
        /// </summary>
        /// <param name="scenePaths">Paths to scenes to include in the AssetBundle. Should be relative to project directory.</param>
        public static void BuildQuickDeployAssetBundle(string[] scenePaths)
        {
            if (scenePaths.Length == 0)
            {
                throw new Exception("No scenes were selected. Please select scenes to include in AssetBundle.");
            }

            if (string.IsNullOrEmpty(QuickDeployWindow.Config.AssetBundleFileName))
            {
                throw new Exception("Cannot build AssetBundle with invalid file name.");
            }

            var assetBundleBuild = new AssetBundleBuild();

            assetBundleBuild.assetBundleName = Path.GetFileName(QuickDeployWindow.Config.AssetBundleFileName);
            assetBundleBuild.assetNames      = scenePaths;
            var assetBundleDirectory = Path.GetDirectoryName(QuickDeployWindow.Config.AssetBundleFileName);

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

            // TODO: Update AssetBundle manifest path in PlayInstantBuildConfiguration.(Requires some refactoring)
            var builtAssetBundleManifest = BuildPipeline.BuildAssetBundles(assetBundleDirectory,
                                                                           new[] { assetBundleBuild }, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);

            // Returned AssetBundleManifest will be null if there was error in building assetbundle.
            if (builtAssetBundleManifest == null)
            {
                throw new Exception(
                          "Could not build AssetBundle. Please ensure that you have properly configured AssetBundle to be built " +
                          "by selecting scenes to include and choosing a valid path for AssetBundle to be stored.");
            }

            // Update AssetBundle manifest path in PlayInstantBuildConfiguration, and refresh the build settings window if it is open.
            var builtAssetBundleManifestPath = string.Format("{0}.manifest", QuickDeployWindow.Config.AssetBundleFileName);

            PlayInstantBuildConfiguration.SaveConfiguration(PlayInstantBuildConfiguration.InstantUrl,
                                                            PlayInstantBuildConfiguration.ScenesInBuild, builtAssetBundleManifestPath);
            BuildSettingsWindow.UpdateWindowIfOpen();
        }