private void PatchSettingsFile(AddressablesDataBuilderInput builderInput)
        {
            // Get the path to the settings.json file
            var settingsJsonPath = Addressables.BuildPath + "/" + builderInput.RuntimeSettingsFilename;

            // Parse the JSON document
            var settingsJson = JsonUtility.FromJson <ResourceManagerRuntimeData>(File.ReadAllText(settingsJsonPath));

            // Look for the remote hash section
            var originalRemoteHashCatalogLocation = settingsJson.CatalogLocations.Find(locationData => locationData.Keys[0] == "AddressablesMainContentCatalogRemoteHash");
            var isRemoteLoadPathValid             = originalRemoteHashCatalogLocation.InternalId.StartsWith("playfab://");

            if (isRemoteLoadPathValid == false)
            {
                throw new BuildFailedException("RemoteBuildPath must start with playfab://");
            }

            // Change the remote hash provider to our PlayFabStorageHashProvider
            var newRemoteHashCatalogLocation = new ResourceLocationData(originalRemoteHashCatalogLocation.Keys, originalRemoteHashCatalogLocation.InternalId, typeof(PlayFabStorageHashProvider), originalRemoteHashCatalogLocation.ResourceType, originalRemoteHashCatalogLocation.Dependencies);

            settingsJson.CatalogLocations.Remove(originalRemoteHashCatalogLocation);
            settingsJson.CatalogLocations.Add(newRemoteHashCatalogLocation);

            File.WriteAllText(settingsJsonPath, JsonUtility.ToJson(settingsJson));
        }
Exemplo n.º 2
0
        protected override TResult DoBuild <TResult>(AddressablesDataBuilderInput builderInput, AddressableAssetsBuildContext aaContext)
        {
            foreach (var assetGroup in builderInput.AddressableSettings.groups)
            {
                var schema = assetGroup.GetSchema <BundledAssetGroupSchema>();
                if (schema == null)
                {
                    continue;
                }

                SerializedType _ty = schema.AssetBundleProviderType;
                if (_ty.Value != typeof(FirebaseStorageAssetBundleProvider))
                {
                    string _errMsg = $"Firebase Build 는 '{assetGroup.name}' Group의 AssetBundleProvider 를 FirebaseStorageAssetBundleProvider 로 바꿔줘야 합니다.";
                    return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, _errMsg));
                }
            }

            //원격빌드이므로 IsRemoteCatalog 값은 true
            builderInput.AddressableSettings.BuildRemoteCatalog = true;

            var result = base.DoBuild <TResult>(builderInput, aaContext);

            var settingsPath = Addressables.BuildPath + "/" + builderInput.RuntimeSettingsFilename;

            var data = JsonUtility.FromJson <ResourceManagerRuntimeData>(File.ReadAllText(settingsPath));

            var remoteHash = data.CatalogLocations.Find(locationData =>
                                                        locationData.Keys[0] == "AddressablesMainContentCatalogRemoteHash");

            if (remoteHash != null)
            {
                var newRemoteHash = new ResourceLocationData(remoteHash.Keys, remoteHash.InternalId,
                                                             typeof(FirebaseStorageHashProvider), remoteHash.ResourceType, remoteHash.Dependencies);

                data.CatalogLocations.Remove(remoteHash);
                data.CatalogLocations.Add(newRemoteHash);
            }

            File.WriteAllText(settingsPath, JsonUtility.ToJson(data));

            Debug.Log($"Player Version : {builderInput.PlayerVersion}");

            return(result);
        }