public void Setup() { m_Seed = 0; BuildCache.PurgeCache(false); // TOOD: If the build cache didn't use global directories, this wouldn't be necessary m_TestTempDir = CreateTempDir("TestTemp"); m_SizeCounts = new Dictionary <int, int>(); }
public void WhenInputsChanges_AndRebuilt_CachedDataIsUsedAsExpected(bool shouldRebuild, Action <RebuildTestContext> postFirstBuildAction) { BuildCache.PurgeCache(false); using (BuildCache cache = new BuildCache()) { RebuildTestContext ctx = new RebuildTestContext(); ctx.input = GetDefaultInput(); ctx._this = this; ctx.input.BuildCache = cache; AddSimpleBundle(ctx.input, "mybundle", "internalName"); ArchiveAndCompressBundles.Run(ctx.input, out ArchiveAndCompressBundles.TaskOutput output); cache.SyncPendingSaves(); Assert.AreEqual(0, ctx.input.OutCachedBundles.Count); postFirstBuildAction(ctx); ctx.input.OutCachedBundles.Clear(); ArchiveAndCompressBundles.Run(ctx.input, out ArchiveAndCompressBundles.TaskOutput outputReRun); if (shouldRebuild) { Assert.AreEqual(0, ctx.input.OutCachedBundles.Count); } else { Assert.AreEqual(1, ctx.input.OutCachedBundles.Count); } } }
public static void BuildBundle() { AddressablesBundleBuildScript.CreatConfig(); AddressableAssetSettings.CleanPlayerContent(); BuildCache.PurgeCache(false); AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilderIndex = 3; AddressableAssetSettings.BuildPlayerContent(); }
protected virtual void PurgeBuildCache() { if (m_Cache != null) { m_Cache.SyncPendingSaves(); } BuildCache.PurgeCache(false); }
protected override void RecreateBuildCache() { // purge the local cache to make sure we don't load anything out of it again. // these tests need to pull from the cache server BuildCache.PurgeCache(); if (m_Cache != null) { m_Cache.Dispose(); } m_Cache = new BuildCache("localhost", LocalCacheServer.instance.m_port); }
public void WhenReferencedObjectIdentifiedWithFilename_ObjectRepresentedInDataFromOtherAssets() { using (new SpritePackerScope(SpritePackerMode.BuildTimeOnlyAtlas)) { BuildCache.PurgeCache(false); AddressableAssetGroup group = CreateGroup("Group1"); string textureGUID = CreateSpriteTexture("spritetexture", 256, false); MakeAddressable(group, CreateSpriteAtlas("atlas", textureGUID)); BuildLayout layout = BuildAndExtractLayout(); BuildLayout.DataFromOtherAsset otherAssets = layout.Groups[0].Bundles[0].Files[0].Assets[0].InternalReferencedOtherAssets[0]; Assert.IsTrue(otherAssets.AssetPath.StartsWith("library/atlascache", StringComparison.OrdinalIgnoreCase)); CollectionAssert.Contains(otherAssets.ReferencingAssets, layout.Groups[0].Bundles[0].Files[0].Assets[0]); } }
private void OnGUI() { m_SerializedObject.Update(); EditorGUILayout.PropertyField(m_TargetProp); EditorGUILayout.PropertyField(m_GroupProp); EditorGUILayout.PropertyField(m_CompressionProp); EditorGUILayout.PropertyField(m_CacheProp); EditorGUILayout.PropertyField(m_ExpProp); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_OutputProp); if (GUILayout.Button("Pick", GUILayout.Width(50))) { PickOutputFolder(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Purge Cache")) { BuildCache.PurgeCache(); } if (GUILayout.Button("Purge Output")) { PurgeOutputFolder(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Open Output")) { OpenOutputFolder(); } if (GUILayout.Button("Build Bundles")) { BuildAssetBundles(); } EditorGUILayout.EndHorizontal(); m_SerializedObject.ApplyModifiedProperties(); }
void OnCleanSBP() { BuildCache.PurgeCache(true); }
public void Setup() { BuildCache.PurgeCache(false); RecreateBuildCache(); SetupDerived(); }
static void Build(Action behaviour) { // Check error if (exportTo == ExportTo.Project && !Directory.Exists(Path.Combine(projectPath, "Assets/StreamingAssets"))) { Debug.LogError("Cannot deploy to project dir as the folder doesn't seem to be an Unity project"); return; } if (exportTo == ExportTo.Game) { bool gameSupported = false; foreach (string supportedGame in Enum.GetNames(typeof(SupportedGame))) { if (File.Exists(Path.Combine(gamePath, supportedGame + ".exe"))) { gameSupported = true; gameName = (SupportedGame)Enum.Parse(typeof(SupportedGame), supportedGame); } } if (!gameSupported) { Debug.LogError("Target game not supported!"); return; } } #if PrivateSDK if (exportTo == ExportTo.Android) { string adbPath = Path.Combine(EditorPrefs.GetString("AndroidSdkRoot"), "platform-tools", "adb.exe"); if (!EditorPrefs.HasKey("AndroidSdkRoot") || !File.Exists(adbPath)) { Debug.LogError("Android SDK is not installed!"); Debug.LogError("Path not found " + adbPath); return; } } #endif // Configure stereo rendering if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) { PlayerSettings.stereoRenderingPath = StereoRenderingPath.SinglePass; } if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows || EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64) { PlayerSettings.stereoRenderingPath = StereoRenderingPath.Instancing; } // Configure addressable groups if (AddressableAssetSettingsDefaultObject.Settings != null) { foreach (AddressableAssetGroup group in AddressableAssetSettingsDefaultObject.Settings.groups) { BundledAssetGroupSchema bundledAssetGroupSchema = group.GetSchema <BundledAssetGroupSchema>(); if (bundledAssetGroupSchema != null) { if (group.Default) { bundledAssetGroupSchema.BuildPath.SetVariableByName(AddressableAssetSettingsDefaultObject.Settings, "LocalBuildPath"); bundledAssetGroupSchema.LoadPath.SetVariableByName(AddressableAssetSettingsDefaultObject.Settings, "LocalLoadPath"); } bundledAssetGroupSchema.BundleNaming = BundledAssetGroupSchema.BundleNamingStyle.NoHash; bundledAssetGroupSchema.BundleNaming = BundledAssetGroupSchema.BundleNamingStyle.NoHash; AddressableAssetSettingsDefaultObject.Settings.profileSettings.SetValue(group.Settings.activeProfileId, "LocalBuildPath", "[ThunderRoad.ModBuilder.buildPath]"); AddressableAssetSettingsDefaultObject.Settings.profileSettings.SetValue(group.Settings.activeProfileId, "LocalLoadPath", (toDefault ? "{ThunderRoad.FileManager.aaDefaultPath}/" : "{ThunderRoad.FileManager.aaModPath}/") + exportFolderName); // Set builtin shader to export folder name to avoid duplicates AddressableAssetSettingsDefaultObject.Settings.ShaderBundleNaming = UnityEditor.AddressableAssets.Build.ShaderBundleNaming.Custom; AddressableAssetSettingsDefaultObject.Settings.ShaderBundleCustomNaming = exportFolderName; AddressableAssetSettingsDefaultObject.Settings.BuildRemoteCatalog = true; /* TODO: OBB support (zip file uncompressed and adb push to obb folder) * AddressableAssetSettingsDefaultObject.Settings.profileSettings.SetValue(group.Settings.activeProfileId, "LocalLoadPath", "{ThunderRoad.FileManager.obbPath}/" + exportFolderName + "{ThunderRoad.FileManager.obbPathEnd}"); */ } } } AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); // Build if (behaviour == Action.BuildAndExport || behaviour == Action.BuildOnly) { Debug.Log("Build path is: " + buildPath); if (OnBuildEvent != null) { OnBuildEvent.Invoke(EventTime.OnStart); } // Clean build path if (Directory.Exists(buildPath)) { foreach (string filePath in Directory.GetFiles(buildPath, "*.*", SearchOption.AllDirectories)) { File.Delete(filePath); } } BuildCache.PurgeCache(true); AddressableAssetSettings.CleanPlayerContent(); AddressableAssetSettings.CleanPlayerContent(AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilder); AddressableAssetSettings.BuildPlayerContent(); Debug.Log("Build done"); if (OnBuildEvent != null) { OnBuildEvent.Invoke(EventTime.OnEnd); } } // Export if (behaviour == Action.BuildAndExport || behaviour == Action.ExportOnly) { if (exportTo == ExportTo.Game || exportTo == ExportTo.Project) { // Get paths string buildFullPath = Path.Combine(Directory.GetCurrentDirectory(), buildPath); string catalogFullPath = Path.Combine(Directory.GetCurrentDirectory(), catalogPath); string destinationAssetsPath = ""; string destinationCatalogPath = ""; if (exportTo == ExportTo.Project) { destinationAssetsPath = Path.Combine(projectPath, buildPath); destinationCatalogPath = Path.Combine(projectPath, catalogPath); } else if (exportTo == ExportTo.Game) { if (toDefault) { destinationAssetsPath = destinationCatalogPath = Path.Combine(gamePath, gameName + "_Data/StreamingAssets/Default", exportFolderName); } else { destinationAssetsPath = destinationCatalogPath = Path.Combine(gamePath, gameName + "_Data/StreamingAssets/Mods", exportFolderName); } } // Create folders if needed if (!File.Exists(destinationAssetsPath)) { Directory.CreateDirectory(destinationAssetsPath); } if (!File.Exists(destinationCatalogPath)) { Directory.CreateDirectory(destinationCatalogPath); } // Clean destination path if (cleanDestination) { foreach (string filePath in Directory.GetFiles(destinationAssetsPath, "*.*", SearchOption.AllDirectories)) { File.Delete(filePath); } if (exportTo == ExportTo.Game) { foreach (string filePath in Directory.GetFiles(destinationCatalogPath, "*.*", SearchOption.AllDirectories)) { File.Delete(filePath); } } } else { foreach (string filePath in Directory.GetFiles(destinationAssetsPath, "catalog_*.json", SearchOption.AllDirectories)) { File.Delete(filePath); } foreach (string filePath in Directory.GetFiles(destinationAssetsPath, "catalog_*.hash", SearchOption.AllDirectories)) { File.Delete(filePath); } if (exportTo == ExportTo.Game) { foreach (string filePath in Directory.GetFiles(destinationCatalogPath, "catalog_*.json", SearchOption.AllDirectories)) { File.Delete(filePath); } foreach (string filePath in Directory.GetFiles(destinationCatalogPath, "catalog_*.hash", SearchOption.AllDirectories)) { File.Delete(filePath); } } } // Copy addressable assets to destination path CopyDirectory(buildFullPath, destinationAssetsPath); Debug.Log("Copied addressable asset folder " + buildFullPath + " to " + destinationAssetsPath); if (exportTo == ExportTo.Game) { // Copy json catalog to destination path CopyDirectory(catalogFullPath, destinationCatalogPath); Debug.Log("Copied catalog folder " + catalogFullPath + " to " + destinationCatalogPath); // Copy plugin dll if any string dllPath = Path.Combine("BuildStaging", "Plugins", exportFolderName) + "/bin/Release/netstandard2.0/" + exportFolderName + ".dll"; if (File.Exists(dllPath)) { File.Copy(dllPath, destinationCatalogPath + "/" + exportFolderName + ".dll", true); Debug.Log("Copied dll " + dllPath + " to " + destinationCatalogPath); } } } if ((exportTo == ExportTo.Game) && runGameAfterBuild) { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = Path.Combine(gamePath, gameName + ".exe"); process.StartInfo.Arguments = runGameArguments; process.Start(); Debug.Log("Start game: " + process.StartInfo.FileName + " " + process.StartInfo.Arguments); } #if PrivateSDK if (exportTo == ExportTo.Android) { string buildFullPath = Path.Combine(Directory.GetCurrentDirectory(), "BuildStaging", "AddressableAssets", "Android"); System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = GetAdbPath(); string destinationPath = "/sdcard/Android/data/com.Warpfrog." + gameName + "/files/mods/" + exportFolderName; process.StartInfo.Arguments = "push " + buildFullPath + "/. " + destinationPath; // for default: obb : /sdcard/Android/obb/" + PlayerSettings.applicationIdentifier + "/main.1.com.Warpfrog.BladeAndSorcery.obb"); process.Start(); process.WaitForExit(); Debug.Log(GetAdbPath() + " " + process.StartInfo.Arguments); if (runGameAfterBuild) { process = new System.Diagnostics.Process(); process.StartInfo.FileName = GetAdbPath(); process.StartInfo.Arguments = "shell am start -n " + PlayerSettings.applicationIdentifier + "/com.unity3d.player.UnityPlayerActivity"; process.Start(); Debug.Log("Start game: " + process.StartInfo.FileName + " " + process.StartInfo.Arguments); } } #endif Debug.Log("Export done"); } // The end System.Media.SystemSounds.Asterisk.Play(); }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Build Addressable Assets: Build Addressable Assets.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(4f); EditorGUILayout.HelpBox("Build Addressable Assets does not respect Platform selection in Graph Editor." + "Instead, Addressable Profile will be used for platform targeting.", MessageType.Info); if (!AddressableAssetSettingsDefaultObject.SettingsExists) { return; } var profileNames = Settings.profileSettings.GetAllProfileNames(); profileNames.Insert(0, kCurrentProfile); var profileIndex = string.IsNullOrEmpty(m_profileName) ? 0 : profileNames.IndexOf(m_profileName); var newProfileIndex = EditorGUILayout.Popup("Profile", profileIndex, profileNames.ToArray()); if (newProfileIndex != profileIndex) { using (new RecordUndoScope("Change Profile", node, true)) { m_profileName = profileNames[newProfileIndex]; onValueChanged(); } } if (m_currentDataBuilder == null && !string.IsNullOrEmpty(m_builderGuid)) { m_currentDataBuilder = Settings.DataBuilders.FirstOrDefault(obj => AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)) == m_builderGuid); } var dataBuilders = Settings.DataBuilders.Where(builder => (builder as IDataBuilder).CanBuildData <AddressablesPlayerBuildResult>()).ToList(); var builderIndex = m_currentDataBuilder == null ? -1 : dataBuilders.IndexOf(m_currentDataBuilder); var builderNames = dataBuilders .Select(builder => ((IDataBuilder)builder).Name).ToArray(); var newIndex = EditorGUILayout.Popup("Builder Script", builderIndex, builderNames); if (newIndex != builderIndex) { using (new RecordUndoScope("Change Builder", node, true)) { m_currentDataBuilder = dataBuilders[newIndex]; m_builderGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_currentDataBuilder)); onValueChanged(); } } var newPreferUpdate = EditorGUILayout.ToggleLeft("Update", m_preferUpdate); if (newPreferUpdate != m_preferUpdate) { using (new RecordUndoScope("Update Toggle", node, true)) { m_preferUpdate = newPreferUpdate; onValueChanged(); } } using (new EditorGUI.DisabledScope(!m_preferUpdate)) { GUILayout.Label("Content State File", "BoldLabel"); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.SelectableLabel(m_contentStateFilePath, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); if (GUILayout.Button("Select", GUILayout.Width(50f))) { var newStateData = ContentUpdateScript.GetContentStateDataPath(true); if (newStateData != null && newStateData != m_contentStateFilePath) { using (new RecordUndoScope("Content State Data Path", node, true)) { m_contentStateFilePath = newStateData; onValueChanged(); } } } } } GUILayout.Space(10f); if (GUILayout.Button("Clean Build Cache", GUILayout.Width(250f))) { if (EditorUtility.DisplayDialog("Clean Build Cache", "Do you really want to clean build cache?", "OK", "Cancel")) { AddressableAssetSettings.CleanPlayerContent(null); BuildCache.PurgeCache(false); } } }
public void OnCleanSBP() { BuildCache.PurgeCache(promtWarning); }
public void Setup() { m_Seed = 0; BuildCache.PurgeCache(false); // TOOD: If the build cache didn't use global directories, this wouldn't be necessary m_TempDir = GetTemporaryDirectory(); }