private static void OnDomainReload()
        {
            var setting = EditorBuildConfigs.GetActiveSettings <BundleIdentifierSetting>();

            if (setting == null)
            {
                return;
            }

            foreach (var buildTargetGroup in BuildTargetGroupUtil.GetValid())
            {
                var currentBundleId = PlayerSettings.GetApplicationIdentifier(buildTargetGroup);

                if (string.IsNullOrEmpty(setting.bundleId))
                {
                    if (string.IsNullOrEmpty(currentBundleId) == false)
                    {
                        setting.bundleId = currentBundleId;
                        break;
                    }
                }
                else if (setting.bundleId != currentBundleId)
                {
                    PlayerSettings.SetApplicationIdentifier(buildTargetGroup, setting.bundleId);
                }
            }
        }
Example #2
0
        private static void OnPreproccessBuild()
        {
            var settings = EditorBuildConfigs.GetActiveSettings <BuildValidatorSettings>();

            if (settings == null)
            {
                return;
            }

            // Validating Prefabs
            foreach (var prefabPath in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.prefab", SearchOption.AllDirectories))
            {
                var prefab = AssetDatabase.LoadAssetAtPath <UnityEngine.GameObject>(prefabPath);

                ValidateComponents(prefab.GetComponentsInChildren(typeof(Component), true));
            }

            // Scriptable Objects
            foreach (var scriptableObjectPath in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.asset", SearchOption.AllDirectories))
            {
                var scriptableObject = AssetDatabase.LoadAssetAtPath(scriptableObjectPath, typeof(UnityEngine.ScriptableObject));
                var serializedObject = new SerializedObject(scriptableObject);

                ValidateSerializedObject(serializedObject);
            }
        }
Example #3
0
        private static void BuildPlayerContent()
        {
            var settings = EditorBuildConfigs.GetActiveSettings <BuildPlayerContentSettings>();

            if (settings != null && settings.buildPlayerContentOnBuild)
            {
                UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.BuildPlayerContent();
            }
        }
Example #4
0
        private static void OnProcessScene(Scene scene, BuildReport report)
        {
            var settings = EditorBuildConfigs.GetActiveSettings <BuildValidatorSettings>();

            if (settings == null)
            {
                return;
            }

            foreach (var rootGameObject in scene.GetRootGameObjects())
            {
                ValidateComponents(rootGameObject.GetComponentsInChildren(typeof(Component), true));
            }
        }
        private static void OnDomainReload()
        {
            var settings = EditorBuildConfigs.GetActiveSettings <AndroidKeystoreSettings>();

            if (settings != null)
            {
                #if UNITY_2019_1_OR_NEWER
                PlayerSettings.Android.useCustomKeystore = settings.useCustomKeystore;
                #endif

                PlayerSettings.Android.keystoreName = settings.keystoreFile;
                PlayerSettings.Android.keystorePass = settings.keystorePassword;
                PlayerSettings.Android.keyaliasName = settings.keyAliasName;
                PlayerSettings.Android.keyaliasPass = settings.keyAliasePassword;
            }
        }
Example #6
0
        private static void OnPreproccessBuild()
        {
            var settings = EditorBuildConfigs.GetActiveSettings <CloudBuildSetBuildNumber>();

            if (settings == null)
            {
                return;
            }

            int buildNumber = GetBuildNumber(settings);

            if (buildNumber != -1)
            {
                PlayerSettings.iOS.buildNumber           = buildNumber.ToString();
                PlayerSettings.Android.bundleVersionCode = buildNumber;
            }
        }
        private static void OnPostprocessBuild(BuildReport buildReport)
        {
            var settings = EditorBuildConfigs.GetActiveSettings <IosSettings>();

            if (settings == null)
            {
                return;
            }

            var path = buildReport.summary.outputPath;

            if (settings == null || buildReport.summary.platform != UnityEditor.BuildTarget.iOS)
            {
                return;
            }

            DisableBitCode(settings, path);
            EnableIOSPushNotifications(settings, path);
        }
        public static void ApplyCurrentSettings()
        {
            var settings = EditorBuildConfigs.GetActiveSettings <P4IgnoreSettings>();

            if (settings == null)
            {
                return;
            }

            if (settings.autoGenerateP4IgnoreFile)
            {
                MenuItemTools.GenerateFile("p4ignore", settings.p4IgnoreFileName, settings.p4IgnoreTemplate.GetGuid());
            }

            if (settings.autosetP4IgnoreVariable)
            {
                SetP4IgnoreFileVariable(settings.p4IgnoreFileName);
            }
        }
        private static void OnPostprocessBuild()
        {
            var settings = EditorBuildConfigs.GetActiveSettings <UploadAddressableToS3Settings>();

            if (settings == null)
            {
                return;
            }

            var s3Settings = GetSettings();

            var s3Config = new S3.Config
            {
                AccessKeyId = s3Settings.AccessKeyId,
                BucketName  = s3Settings.BucketName,
                SecretKeyId = s3Settings.SecretKeyId,
            };

            foreach (var filePath in Directory.GetFiles(s3Settings.AssetBundleFolderName, "*", SearchOption.AllDirectories))
            {
                S3.UploadFile(s3Config, s3Settings.KeyPrefix + Path.GetFileName(filePath), File.ReadAllBytes(filePath), false);
            }
        }
        private static void OnPostGenerateGradleAndroidProject(string gradlePath)
        {
            var settings = EditorBuildConfigs.GetActiveSettings <AndroidXSetting>();

            if (settings == null || settings.overrideGradleProperties == false)
            {
                return;
            }

            string gradlePropertiesFile = gradlePath + "/gradle.properties";

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

            StreamWriter writer = File.CreateText(gradlePropertiesFile);

            writer.WriteLine("org.gradle.jvmargs=-Xmx4096M");
            writer.WriteLine("android.useAndroidX=" + settings.useAndroidX.ToString().ToLower());
            writer.WriteLine("android.enableJetifier=" + settings.enableJetifier.ToString().ToLower());
            writer.Flush();
            writer.Close();
        }
Example #11
0
        private static void OnPreproccessBuild()
        {
            var settings = EditorBuildConfigs.GetActiveSettings <CopyCloudBuildDLLSettings>();

            if (settings == null || settings.copyCloudBuildDLLToStreamingAssets == false || Platform.IsUnityCloudBuild == false)
            {
                return;
            }

            foreach (var file in Directory.GetFiles(".", "*", SearchOption.AllDirectories))
            {
                if (Path.GetFileName(file) == "UnityEditor.CloudBuild.dll")
                {
                    // Making sure the directory path exists and copying it over
                    string copyPath = "Assets/StreamingAssets/UnityEditor.CloudBuild.dll.copy";
                    Directory.CreateDirectory(Path.GetDirectoryName(copyPath));
                    File.Copy(file, copyPath);

                    // Importing the asset so it will be included in the build
                    AssetDatabase.ImportAsset(copyPath);
                    AssetDatabase.Refresh();
                }
            }
        }
Example #12
0
        private static void OnPostprocessBuild()
        {
            var uploadToAzureSettings = EditorBuildConfigs.GetActiveSettings <UploadAddressableToAzureSettings>();

            if (uploadToAzureSettings == null)
            {
                return;
            }

            var azureConfig = new AzureStorage.Config
            {
                StorageAccountName = uploadToAzureSettings.storageAccountName,
                StorageAccountKey  = uploadToAzureSettings.storageAccountKey,
                ContainerName      = uploadToAzureSettings.containerName,
            };

            // makding sure the asset bundle path doesn't end with a forward slash
            string assetBundlePath = uploadToAzureSettings.CalculateBuildPath();

            if (Directory.Exists(assetBundlePath) == false)
            {
                if (IsBeingUsedByAddressableSystem())
                {
                    Debug.LogErrorFormat("Unable to Upload AssetBundles To Azure.  Directory {0} does not exist.", assetBundlePath);
                }

                return;
            }

            string           blobPrefix    = GetBlobPrefix(uploadToAzureSettings);
            HashSet <string> existingFiles = GetExistingFiles(azureConfig, blobPrefix);

            foreach (var filePath in Directory.GetFiles(assetBundlePath, "*", SearchOption.AllDirectories))
            {
                string relativeFileName = filePath.Substring(assetBundlePath.Length + 1).Replace("\\", "/");
                string blobName         = blobPrefix + "/" + relativeFileName;

                if (existingFiles.Contains(blobName))
                {
                    Debug.LogFormat("Skipping AssetBundle {0}, it already exists", blobName, azureConfig.StorageAccountName);
                    continue;
                }

                Debug.LogFormat("Uploading AssetBundle {0}", blobName, azureConfig.StorageAccountName);

                try
                {
                    AzureStorage.UploadFile(azureConfig, blobName, File.ReadAllBytes(filePath));
                }
                catch (Exception exception)
                {
                    Debug.LogErrorFormat("Error uploading AssetBundle {0} To Azure.", blobName);
                    Debug.LogException(exception);

                    #if UNITY_CLOUD_BUILD
                    EditorApplication.Exit(1);
                    #endif

                    return;
                }
            }
        }