/// <inheritdoc /> protected override TResult BuildDataImplementation <TResult>(AddressablesDataBuilderInput builderInput) { TResult result = default(TResult); var timer = new Stopwatch(); timer.Start(); var aaSettings = builderInput.AddressableSettings; var locations = new List <ContentCatalogDataEntry>(); m_AllBundleInputDefs = new List <AssetBundleBuild>(); var bundleToAssetGroup = new Dictionary <string, string>(); var runtimeData = new ResourceManagerRuntimeData(); runtimeData.CertificateHandlerType = aaSettings.CertificateHandlerType; runtimeData.BuildTarget = builderInput.Target.ToString(); runtimeData.ProfileEvents = builderInput.ProfilerEventsEnabled; runtimeData.LogResourceManagerExceptions = aaSettings.buildSettings.LogResourceManagerExceptions; m_Linker = new LinkXmlGenerator(); m_Linker.SetTypeConversion(typeof(UnityEditor.Animations.AnimatorController), typeof(RuntimeAnimatorController)); m_Linker.AddTypes(runtimeData.CertificateHandlerType); m_ResourceProviderData = new List <ObjectInitializationData>(); var aaContext = new AddressableAssetsBuildContext { settings = aaSettings, runtimeData = runtimeData, bundleToAssetGroup = bundleToAssetGroup, locations = locations, providerTypes = new HashSet <Type>() }; m_CreatedProviderIds = new HashSet <string>(); var errorString = ProcessAllGroups(aaContext); if (!string.IsNullOrEmpty(errorString)) { result = AddressableAssetBuildResult.CreateResult <TResult>(null, 0, errorString); } if (result == null) { result = DoBuild <TResult>(builderInput, aaContext); } if (result != null) { result.Duration = timer.Elapsed.TotalSeconds; } return(result); }
public void Build_WithAddrParentFolderAndAddrSubfolders_InSeparateGroups_Succeeds() { var context = new AddressablesDataBuilderInput(Settings); foreach (IDataBuilder db in Settings.DataBuilders) { if (db.CanBuildData <AddressablesPlayerBuildResult>()) { db.BuildData <AddressablesPlayerBuildResult>(context); } } }
public void BuildScript_DoesNotBuildWrongDataType() { var context = new AddressablesDataBuilderInput(Settings); var baseScript = ScriptableObject.CreateInstance <BuildScriptTestClass>(); baseScript.BuildData <AddressablesPlayerBuildResult>(context); LogAssert.Expect(LogType.Error, new Regex("Data builder Test Script cannot build requested type.*")); baseScript.BuildData <AddressablesPlayModeBuildResult>(context); LogAssert.Expect(LogType.Error, "Inside BuildDataInternal for test script!"); }
protected override TResult BuildDataImplementation <TResult>(AddressablesDataBuilderInput context) { m_Settings = context.AddressableSettings; foreach (var group in m_Settings.groups) { ProcessGroup(group, null); } var result = base.BuildDataImplementation <TResult>(context); m_UsingVariantFastMode = true; return(result); }
protected override TResult DoBuild <TResult>(AddressablesDataBuilderInput builderInput, AddressableAssetsBuildContext aaContext) { var buildResult = base.DoBuild <TResult>(builderInput, aaContext); if (aaContext.settings.BuildRemoteCatalog) { PatchSettingsFile(builderInput); } else { Debug.LogWarning("[TheGamedevGuru] PlayFab: Addressables Remote Catalog is not enabled, skipping patching of the settings file"); } return(buildResult); }
/// <inheritdoc /> protected override TResult BuildDataImplementation <TResult>(AddressablesDataBuilderInput builderInput) { var timer = new System.Diagnostics.Stopwatch(); timer.Start(); var settingsPath = Addressables.BuildPath + "/settings.json"; if (!File.Exists(settingsPath)) { IDataBuilderResult resE = new AddressablesPlayModeBuildResult() { Error = "Player content must be built before entering play mode with packed data. This can be done from the Addressable Assets window in the Build->Build Player Content menu command." }; return((TResult)resE); } var rtd = JsonUtility.FromJson <ResourceManagerRuntimeData>(File.ReadAllText(settingsPath)); if (rtd == null) { IDataBuilderResult resE = new AddressablesPlayModeBuildResult() { Error = string.Format("Unable to load initialization data from path {0}. This can be done from the Addressable Assets window in the Build->Build Player Content menu command.", settingsPath) }; return((TResult)resE); } BuildTarget dataBuildTarget = BuildTarget.NoTarget; if (!Enum.TryParse(rtd.BuildTarget, out dataBuildTarget)) { Debug.LogWarningFormat("Unable to parse build target from initialization data: '{0}'.", rtd.BuildTarget); } if (BuildPipeline.GetBuildTargetGroup(dataBuildTarget) != BuildTargetGroup.Standalone) { Debug.LogWarningFormat("Asset bundles built with build target {0} may not be compatible with running in the Editor.", dataBuildTarget); } //TODO: detect if the data that does exist is out of date.. var runtimeSettingsPath = "{UnityEngine.AddressableAssets.Addressables.RuntimePath}/settings.json"; PlayerPrefs.SetString(Addressables.kAddressablesRuntimeDataPath, runtimeSettingsPath); IDataBuilderResult res = new AddressablesPlayModeBuildResult() { OutputPath = settingsPath, Duration = timer.Elapsed.TotalSeconds }; m_DataBuilt = true; return((TResult)res); }
public void BuildInput_CreatesProperBuildData() { var input = new AddressablesDataBuilderInput(Settings); Assert.AreEqual(EditorUserBuildSettings.activeBuildTarget, input.Target); Assert.AreEqual(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget), input.TargetGroup); Assert.AreEqual(Settings.PlayerBuildVersion, input.PlayerVersion); input = new AddressablesDataBuilderInput(Settings, "1234"); Assert.AreEqual(EditorUserBuildSettings.activeBuildTarget, input.Target); Assert.AreEqual(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget), input.TargetGroup); Assert.AreEqual("1234", input.PlayerVersion); }
/// <summary> /// Build the specified data with the provided builderInput. This is the public entry point. /// Child class overrides should use <see cref="BuildDataImplementation{TResult}"/> /// </summary> /// <typeparam name="TResult">The type of data to build.</typeparam> /// <param name="builderInput">The builderInput object used in the build.</param> /// <returns>The build data result.</returns> public TResult BuildData <TResult>(AddressablesDataBuilderInput builderInput) where TResult : IDataBuilderResult { if (!CanBuildData <TResult>()) { var message = "Data builder " + Name + " cannot build requested type: " + typeof(TResult); Debug.LogError(message); return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, message)); } m_Log = (builderInput.Logger != null) ? builderInput.Logger : new BuildLog(); AddressablesRuntimeProperties.ClearCachedPropertyValues(); TResult result = default; // Append the file registry to the results using (m_Log.ScopedStep(LogLevel.Info, $"Building {this.Name}")) { try { result = BuildDataImplementation <TResult>(builderInput); } catch (Exception e) { string errMessage; if (e.Message == "path") { errMessage = "Invalid path detected during build. Check for unmatched brackets in your active profile's variables."; } else { errMessage = e.Message; } Debug.LogError(errMessage); return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, errMessage)); } if (result != null) { result.FileRegistry = builderInput.Registry; } } if (builderInput.Logger == null && m_Log != null) { WriteBuildLog((BuildLog)m_Log, Path.GetDirectoryName(Application.dataPath) + "/" + Addressables.LibraryPath); } return(result); }
public void WarningIsLogged_WhenAddressableGroupDoesNotContainSchema() { var buildScript = ScriptableObject.CreateInstance <BuildScriptPackedMode>(); AddressablesDataBuilderInput input = m_BuilderInput; var group = input.AddressableSettings.CreateGroup("Invalid Group", false, false, false, new List <AddressableAssetGroupSchema>()); buildScript.BuildData <AddressableAssetBuildResult>(input); LogAssert.Expect(LogType.Warning, $"{group.Name} does not have any associated AddressableAssetGroupSchemas. " + $"Data from this group will not be included in the build. " + $"If this is unexpected the AddressableGroup may have become corrupted."); input.AddressableSettings.RemoveGroup(group); }
void RunBuilder(AddressableAssetSettings settings) { var buildContext = new AddressablesDataBuilderInput(settings); buildContext.RuntimeSettingsFilename = "settings" + m_UniqueTestName + ".json"; buildContext.RuntimeCatalogFilename = "catalog" + m_UniqueTestName + ".json"; buildContext.PathFormat = "{0}Library/com.unity.addressables/{1}_" + m_UniqueTestName + ".json"; if (BuildScriptMode == TestBuildScriptMode.PackedPlaymode) { IDataBuilder packedModeBuilder = GetBuilderOfType(settings, typeof(BuildScriptPackedMode)); packedModeBuilder.BuildData <AddressableAssetBuildResult>(buildContext); } IDataBuilder b = GetBuilderOfType(settings, GetBuildScriptTypeFromMode(BuildScriptMode)); b.BuildData <AddressableAssetBuildResult>(buildContext); }
public void BuildInput_ReadsProfilerEventState() { var oldState = ProjectConfigData.PostProfilerEvents; ProjectConfigData.PostProfilerEvents = true; var input = new AddressablesDataBuilderInput(Settings); Assert.AreEqual(true, input.ProfilerEventsEnabled); ProjectConfigData.PostProfilerEvents = false; input = new AddressablesDataBuilderInput(Settings); Assert.AreEqual(false, input.ProfilerEventsEnabled); ProjectConfigData.PostProfilerEvents = oldState; }
protected override TResult DoBuild <TResult>(AddressablesDataBuilderInput builderInput, AddressableAssetsBuildContext aaContext) { if (Directory.Exists(ETModel.PathHelper.RemoteBuildPath)) { FileHelper.CleanDirectory(ETModel.PathHelper.RemoteBuildPath); } if (Directory.Exists(ETModel.PathHelper.BuildPath)) { FileHelper.CleanDirectory(ETModel.PathHelper.BuildPath); } var result = base.DoBuild <TResult>(builderInput, aaContext); var filepath = ETModel.PathHelper.RemoteBuildPath; BuildVerison(filepath); FileHelper.CopyDirectory(PathHelper.RemoteBuildPath, PathHelper.BuildPath); return(result); }
protected virtual void RunBuilder(AddressableAssetSettings settings) { var buildContext = new AddressablesDataBuilderInput(settings); buildContext.RuntimeSettingsFilename = "settings" + m_UniqueTestName + ".json"; buildContext.RuntimeCatalogFilename = "catalog" + m_UniqueTestName + ".json"; buildContext.PathFormat = "{0}" + Addressables.LibraryPath + "{1}_" + m_UniqueTestName + ".json"; if (BuildScriptMode == TestBuildScriptMode.PackedPlaymode) { IDataBuilder packedModeBuilder = GetBuilderOfType(settings, typeof(BuildScriptPackedMode)); packedModeBuilder.BuildData <AddressableAssetBuildResult>(buildContext); } IDataBuilder b = GetBuilderOfType(settings, GetBuildScriptTypeFromMode(BuildScriptMode)); b.BuildData <AddressableAssetBuildResult>(buildContext); PlayerPrefs.SetString(Addressables.kAddressablesRuntimeDataPath + m_UniqueTestName, PlayerPrefs.GetString(Addressables.kAddressablesRuntimeDataPath, "")); }
public void WhenFileTypeIsInvalid_AndContentCatalogsAreCreated_IgnoreUnsupportedFilesInBuildIsSet_BuildSucceedWithWarning() { bool oldValue = Settings.IgnoreUnsupportedFilesInBuild; Settings.IgnoreUnsupportedFilesInBuild = true; var context = new AddressablesDataBuilderInput(Settings); string path = GetAssetPath("fake.file"); FileStream fs = File.Create(path); fs.Close(); AssetDatabase.ImportAsset(path); string guid = AssetDatabase.AssetPathToGUID(path); AddressableAssetEntry entry = Settings.CreateOrMoveEntry(guid, Settings.DefaultGroup); foreach (BuildScriptBase db in Settings.DataBuilders.OfType <BuildScriptBase>()) { if (db.GetType() == typeof(BuildScriptFastMode) || db.GetType() == typeof(BuildScriptPackedPlayMode)) { continue; } if (db.CanBuildData <AddressablesPlayerBuildResult>()) { var res = db.BuildData <AddressablesPlayerBuildResult>(context); Assert.IsTrue(db.IsDataBuilt()); Assert.IsTrue(string.IsNullOrEmpty(res.Error)); } else if (db.CanBuildData <AddressablesPlayModeBuildResult>()) { var res = db.BuildData <AddressablesPlayModeBuildResult>(context); Assert.IsTrue(db.IsDataBuilt()); Assert.IsTrue(string.IsNullOrEmpty(res.Error)); } LogAssert.Expect(LogType.Warning, new Regex($".*{path}.*ignored")); LogAssert.Expect(LogType.Warning, new Regex($".*{path}.*stripped")); } Settings.RemoveAssetEntry(guid, false); AssetDatabase.DeleteAsset(path); Settings.IgnoreUnsupportedFilesInBuild = oldValue; }
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); }
static void RunBuilder(AddressableAssetSettings settings, string testType, string suffix) { var buildContext = new AddressablesDataBuilderInput(settings); buildContext.RuntimeSettingsFilename = "settings" + suffix + ".json"; buildContext.RuntimeCatalogFilename = "catalog" + suffix + ".json"; foreach (var db in settings.DataBuilders) { var b = db as IDataBuilder; if (b.GetType().Name != testType) { continue; } buildContext.PathFormat = "{0}Library/com.unity.addressables/{1}_" + testType + "_TEST_" + suffix + ".json"; b.BuildData <AddressableAssetBuildResult>(buildContext); } }
protected override TResult DoBuild <TResult>(AddressablesDataBuilderInput builderInput, AddressableAssetsBuildContext aaContext) { // Build AssetBundles TResult result = base.DoBuild <TResult>(builderInput, aaContext); // Don't prepare content for asset packs if the build target isn't set to Android if (builderInput.Target != BuildTarget.Android) { Addressables.LogWarning("Build target is not set to Android. No custom asset pack config files will be created."); return(result); } var resetAssetPackSchemaData = !CustomAssetPackSettings.SettingsExists; var customAssetPackSettings = CustomAssetPackSettings.GetSettings(true); CreateCustomAssetPacks(aaContext.Settings, customAssetPackSettings, resetAssetPackSchemaData); return(result); }
public void Folder_DoesNotAssignBundleFileId_ForDynamicallyCreatedSubEntries() { var context = new AddressablesDataBuilderInput(Settings); string folderGuid = AssetDatabase.CreateFolder(TestFolder, "FolderAsset"); string folderPath = $"{TestFolder}/FolderAsset"; PrefabUtility.SaveAsPrefabAsset(new GameObject(), $"{folderPath}/subfolderprefab.prefab"); AddressableAssetEntry folderEntry = Settings.CreateOrMoveEntry(folderGuid, Settings.DefaultGroup); Settings.ActivePlayerDataBuilder.BuildData <AddressablesPlayerBuildResult>(context); Assert.True(string.IsNullOrEmpty(folderEntry.SubAssets[0].BundleFileId)); //Cleanup AssetDatabase.DeleteAsset(folderPath); Settings.RemoveAssetEntry(folderEntry); }
static void CheckVisualAssets() { string[] visualsPath = AddressablesPackagePaths.GetAddressablesPackagePath(); DirectoryInfo info = new DirectoryInfo(visualsPath[0]); DirectoryInfo[] directories = info.GetDirectories(); foreach (DirectoryInfo directory in directories) { DirectoryInfo[] subDirectories = directory.GetDirectories(); string path = visualsPath[0] + "/" + directory.Name; foreach (DirectoryInfo subDirectory in subDirectories) { string addressableGroupName = subDirectory.Name; string subPath = path + "/" + addressableGroupName; AddressableAssetGroup group = FindOrCreateAddressableGroup(addressableGroupName); if (group == null) { Debug.Log("Group is null!"); continue; } FileInfo[] filesInFolder = subDirectory.GetFiles("*", SearchOption.AllDirectories); foreach (FileInfo fileInfo in filesInFolder) { if (fileInfo.Name.Contains(".meta")) { continue; } CreateOrUpdateAddressableAssetEntry(group, subPath, fileInfo.Name); } } } AddressablesDataBuilderInput buildContext = new AddressablesDataBuilderInput(settings, "1"); settings.ActivePlayerDataBuilder.BuildData <AddressablesPlayerBuildResult>(buildContext); }
internal bool CreateCatalogFiles(string jsonText, AddressablesDataBuilderInput builderInput, AddressableAssetsBuildContext aaContext) { if (string.IsNullOrEmpty(jsonText) || builderInput == null || aaContext == null) { Addressables.LogError("Unable to create content catalog (Null arguments)."); return(false); } // Path needs to be resolved at runtime. string localLoadPath = "{UnityEngine.AddressableAssets.Addressables.RuntimePath}/" + builderInput.RuntimeCatalogFilename; m_CatalogBuildPath = Path.Combine(Addressables.BuildPath, builderInput.RuntimeCatalogFilename); if (aaContext.settings.BundleLocalCatalog) { localLoadPath = localLoadPath.Replace(".json", ".bundle"); m_CatalogBuildPath = m_CatalogBuildPath.Replace(".json", ".bundle"); var returnCode = CreateCatalogBundle(m_CatalogBuildPath, jsonText, builderInput); if (returnCode != ReturnCode.Success || !File.Exists(m_CatalogBuildPath)) { Addressables.LogError($"An error occured during the creation of the content catalog bundle (return code {returnCode})."); return(false); } } else { WriteFile(m_CatalogBuildPath, jsonText, builderInput.Registry); } string[] dependencyHashes = null; if (aaContext.settings.BuildRemoteCatalog) { dependencyHashes = CreateRemoteCatalog(jsonText, aaContext.runtimeData.CatalogLocations, aaContext.settings, builderInput); } aaContext.runtimeData.CatalogLocations.Add(new ResourceLocationData( new[] { ResourceManagerRuntimeData.kCatalogAddress }, localLoadPath, typeof(ContentCatalogProvider), typeof(ContentCatalogData), dependencyHashes)); return(true); }
public void Folder_WithNoSubAssets_DoesNotThrowErrorDuringBuild() { var context = new AddressablesDataBuilderInput(Settings); string folderGuid = AssetDatabase.CreateFolder(TestFolder, "FolderAsset"); string folderPath = $"{TestFolder}/FolderAsset"; AddressableAssetEntry folderEntry = Settings.CreateOrMoveEntry(folderGuid, Settings.DefaultGroup); Assert.IsTrue(string.IsNullOrEmpty(folderEntry.BundleFileId)); Settings.ActivePlayerDataBuilder.BuildData <AddressablesPlayerBuildResult>(context); Assert.IsTrue(folderEntry.IsFolder); Assert.IsTrue(string.IsNullOrEmpty(folderEntry.BundleFileId)); //Cleanup AssetDatabase.DeleteAsset(folderPath); Settings.RemoveAssetEntry(folderEntry); }
/// <summary> /// Build the specified data with the provided builderInput. This is the public entry point. /// Child class overrides should use <see cref="BuildDataImplementation{TResult}"/> /// </summary> /// <typeparam name="TResult">The type of data to build.</typeparam> /// <param name="builderInput">The builderInput object used in the build.</param> /// <returns>The build data result.</returns> public TResult BuildData <TResult>(AddressablesDataBuilderInput builderInput) where TResult : IDataBuilderResult { if (!CanBuildData <TResult>()) { var message = "Data builder " + Name + " cannot build requested type: " + typeof(TResult); Debug.LogError(message); return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, message)); } // Append the file registry to the results var result = BuildDataImplementation <TResult>(builderInput); if (result != null) { result.FileRegistry = builderInput.Registry; } return(result); }
static void RunBuilder(AddressableAssetSettings settings, string testType, string suffix) { var buildContext = new AddressablesDataBuilderInput(settings); buildContext.RuntimeSettingsFilename = "settings" + suffix + ".json"; buildContext.RuntimeCatalogFilename = "catalog" + suffix + ".json"; foreach (var db in settings.DataBuilders) { var b = db as IDataBuilder; if (b.GetType().Name != testType) { continue; } buildContext.PathFormat = "{0}" + Addressables.LibraryPath + "{1}_" + testType + "_TEST_" + suffix + ".json"; b.BuildData <AddressableAssetBuildResult>(buildContext); PlayerPrefs.SetString(Addressables.kAddressablesRuntimeDataPath + testType, PlayerPrefs.GetString(Addressables.kAddressablesRuntimeDataPath, "")); } }
private static async void PerformAddressablesCleanBuild() { stopWatch = Stopwatch.StartNew(); UnityEngine.Debug.Log($"PerformAddressablesCleanBuild: {DateTime.UtcNow.ToLocalTime()}"); var settings = AddressableAssetSettingsDefaultObject.Settings; if (settings == null) { UnityEngine.Debug.LogError("AddressableDefaultObject Setting is null"); return; } var buildInput = new AddressablesDataBuilderInput( settings ); AddressablesPlayerBuildResult addressablesPlayerBuildResult = settings.ActivePlayerDataBuilder.BuildData <AddressablesPlayerBuildResult>(buildInput); await Task.Delay(TimeSpan.FromSeconds(addressablesPlayerBuildResult.Duration)); UnityEngine.Debug.Log($"Addressable build took {stopWatch.Elapsed.Seconds} seconds..."); }
protected void TearDown() { m_BuilderInput = null; Object.DestroyImmediate(m_BuildScript); m_BuildScript = null; m_AssetBundle?.Unload(true); m_AssetBundle = null; Object.DestroyImmediate(m_PersistedSettings, true); m_PersistedSettings = null; EditorBuildSettings.scenes = m_ScenesBkp; AssetDatabase.Refresh(); if (Directory.Exists(k_SchemaTestFolder)) { Directory.Delete(k_SchemaTestFolder, true); } AssetDatabase.Refresh(); }
public void Build_WithDeletedAsset_Succeeds() { var context = new AddressablesDataBuilderInput(Settings); //make an entry with no actual AssetPath Settings.CreateOrMoveEntry("abcde", Settings.DefaultGroup); foreach (IDataBuilder db in Settings.DataBuilders) { if (db.CanBuildData <AddressablesPlayerBuildResult>()) { db.BuildData <AddressablesPlayerBuildResult>(context); } else if (db.CanBuildData <AddressablesPlayModeBuildResult>()) { db.BuildData <AddressablesPlayModeBuildResult>(context); } } Settings.RemoveAssetEntry("abcde", false); }
public void BuildContentUpdate_DoesNotDeleteBuiltData() { var group = Settings.CreateGroup("LocalStuff3", false, false, false, null); var schema = group.AddSchema <BundledAssetGroupSchema>(); schema.BuildPath.SetVariableByName(Settings, AddressableAssetSettings.kLocalBuildPath); schema.LoadPath.SetVariableByName(Settings, AddressableAssetSettings.kLocalLoadPath); schema.BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackTogether; group.AddSchema <ContentUpdateGroupSchema>().StaticContent = true; Settings.CreateOrMoveEntry(m_AssetGUID, group); var context = new AddressablesDataBuilderInput(Settings); var op = Settings.ActivePlayerDataBuilder.BuildData <AddressablesPlayerBuildResult>(context); Assert.IsTrue(string.IsNullOrEmpty(op.Error), op.Error); var tempPath = Path.GetDirectoryName(Application.dataPath) + "/Library/com.unity.addressables/StreamingAssetsCopy/" + PlatformMappingService.GetPlatform() + "/addressables_content_state.bin"; ContentUpdateScript.BuildContentUpdate(Settings, tempPath); Assert.IsTrue(Directory.Exists(Addressables.BuildPath)); }
public void Build_WithInvalidAssetInResourcesFolder_Succeeds() { var path = GetAssetPath("Resources/unknownAsset.plist"); if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(path))) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path)); } System.IO.File.WriteAllText(path, "nothing"); AssetDatabase.ImportAsset(path); var context = new AddressablesDataBuilderInput(Settings); foreach (IDataBuilder db in Settings.DataBuilders) { if (db.CanBuildData <AddressablesPlayerBuildResult>()) { db.BuildData <AddressablesPlayerBuildResult>(context); } } }
public void WhenBundleLocalCatalogEnabled_BuildScriptPacked_DoesNotCreatePerformanceLogReport() { string logPath = $"Library/com.unity.addressables/aa/{PlatformMappingService.GetPlatformPathSubFolder()}/buildlogtep.json"; if (File.Exists(logPath)) { File.Delete(logPath); } Settings.BundleLocalCatalog = true; var context = new AddressablesDataBuilderInput(Settings); BuildScriptBase db = (BuildScriptBase)Settings.DataBuilders.Find(x => x.GetType() == typeof(BuildScriptPackedMode)); Assert.IsFalse(File.Exists(logPath)); // make sure file does not exist before build var res = db.BuildData <AddressablesPlayerBuildResult>(context); Assert.IsFalse(File.Exists(logPath)); }
public void Build_GroupWithPlayerDataGroupSchemaAndBundledAssetGroupSchema_LogsError() { const string groupName = "NewGroup"; var schemas = new List <AddressableAssetGroupSchema> { ScriptableObject.CreateInstance <PlayerDataGroupSchema>(), ScriptableObject.CreateInstance <BundledAssetGroupSchema>() }; AddressableAssetGroup group = Settings.CreateGroup(groupName, false, false, false, schemas); var context = new AddressablesDataBuilderInput(Settings); foreach (IDataBuilder db in Settings.DataBuilders) { if (db.CanBuildData <AddressablesPlayerBuildResult>()) { AddressablesPlayerBuildResult result = db.BuildData <AddressablesPlayerBuildResult>(context); Assert.AreEqual(result.Error, $"Addressable group {groupName} cannot have both a {typeof(PlayerDataGroupSchema).Name} and a {typeof(BundledAssetGroupSchema).Name}"); } } Settings.RemoveGroup(group); }