public static void UpdateGroups() { string statePath = "Artifacts/addressables_content_state.bin"; List <AddressableAssetEntry> entries = ContentUpdateScript.GatherModifiedEntries(AddressableAssetSettingsDefaultObject.Settings, statePath); ContentUpdateScript.CreateContentUpdateGroup(AddressableAssetSettingsDefaultObject.Settings, entries, "Update Group"); }
public static void CheckForUpdateContent() { //与上次打包做资源对比 string buildPath = ContentUpdateScript.GetContentStateDataPath(false); var m_Settings = AddressableAssetSettingsDefaultObject.Settings; List <AddressableAssetEntry> entrys = ContentUpdateScript.GatherModifiedEntries(m_Settings, buildPath); if (entrys.Count == 0) { Debug.Log("没有资源变更"); return; } StringBuilder sbuider = new StringBuilder(); sbuider.AppendLine("Need Update Assets:"); foreach (var _ in entrys) { sbuider.AppendLine(_.address); } Debug.Log(sbuider.ToString()); //将被修改过的资源单独分组---可以自定义组名 var groupName = string.Format("UpdateGroup_{0}", DateTime.Now.ToString("yyyyMMddHHmmss")); ContentUpdateScript.CreateContentUpdateGroup(m_Settings, entrys, groupName); }
public void OnGUI() { if (m_DepEntriesMap == null) { return; } Rect contentRect = new Rect(0, 0, position.width, position.height - 50); if (m_Tree == null) { if (m_TreeState == null) { m_TreeState = new TreeViewState(); } var headerState = ContentUpdateTreeView.CreateDefaultMultiColumnHeaderState(); if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_Mchs, headerState)) { MultiColumnHeaderState.OverwriteSerializedFields(m_Mchs, headerState); } m_Mchs = headerState; m_Tree = new ContentUpdateTreeView(this, m_TreeState, m_Mchs); m_Tree.Reload(); } if (m_DepEntriesMap.Count == 0) { GUILayout.BeginArea(contentRect); GUILayout.BeginVertical(); GUILayout.Label("No Addressable groups with a BundledAssetGroupSchema and ContentUpdateGroupSchema (with StaticContent enabled) appear to have been modified."); GUILayout.EndVertical(); GUILayout.EndArea(); } else { m_Tree.OnGUI(contentRect); } GUILayout.BeginArea(new Rect(0, position.height - 50, position.width, 50)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { Close(); } using (new EditorGUI.DisabledScope(m_Tree.GetEnabledEntries().Count == 0)) { if (GUILayout.Button("Apply Changes")) { ContentUpdateScript.CreateContentUpdateGroup(m_Settings, m_Tree.GetEnabledEntries(), "Content Update"); Close(); } } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
public static void CheckForContentUpdate() { BuildLuaAndProto(); var buildPath = ContentUpdateScript.GetContentStateDataPath(false); var settings = AddressableAssetSettingsDefaultObject.Settings; var entrys = ContentUpdateScript.GatherModifiedEntries(settings, buildPath); if (entrys.Count == 0) { return; } var groupName = string.Format("UpdateGroup_{0}", System.DateTime.Now.ToString("yyyyMMdd")); ContentUpdateScript.CreateContentUpdateGroup(settings, entrys, groupName); }
public void OnGUI() { if (m_Entries == null) { return; } Rect contentRect = new Rect(0, 0, position.width, position.height - 50); if (m_Tree == null) { if (m_TreeState == null) { m_TreeState = new TreeViewState(); } var headerState = ContentUpdateTreeView.CreateDefaultMultiColumnHeaderState(); if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_Mchs, headerState)) { MultiColumnHeaderState.OverwriteSerializedFields(m_Mchs, headerState); } m_Mchs = headerState; m_Tree = new ContentUpdateTreeView(this, m_TreeState, m_Mchs); m_Tree.Reload(); } m_Tree.OnGUI(contentRect); GUILayout.BeginArea(new Rect(0, position.height - 50, position.width, 50)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { Close(); } using (new EditorGUI.DisabledScope(m_Tree.GetEnabledEntries().Count == 0)) { if (GUILayout.Button("Apply Changes")) { ContentUpdateScript.CreateContentUpdateGroup(m_Settings, m_Tree.GetEnabledEntries(), "Content Update"); Close(); } } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
private static void UpdateAddressablesBuild() { ExitCode code = ExitCode.UnknownError; BuildScript.buildCompleted += result => { if (!string.IsNullOrEmpty(result.Error)) { code = ExitCode.AddressablesBuildFailed; } else { code = ExitCode.Success; } }; // find out what version we are updating string statePath = "Artifacts/addressables_content_state.bin"; var state = ContentUpdateScript.LoadContentState(statePath); if (state != null) { Debug.Log("State file found, " + state.playerVersion); } code = state == null ? ExitCode.AddressablesContentFileNotFound : ExitCode.Success; List <AddressableAssetEntry> entries = ContentUpdateScript.GatherModifiedEntries(AddressableAssetSettingsDefaultObject.Settings, statePath); foreach (AddressableAssetEntry assetEntry in entries) { Debug.Log("Entry found to be moved - " + assetEntry.address); } Debug.Log("Creating update group"); ContentUpdateScript.CreateContentUpdateGroup(AddressableAssetSettingsDefaultObject.Settings, entries, "Update Group"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, statePath); // TODO edit catalog name. ExitOnError(code); }
public void PrepareContentUpdate() { var group = Settings.CreateGroup("LocalStuff2", 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; var entry = Settings.CreateOrMoveEntry(m_AssetGUID, group); entry.address = "test"; var context = new AddressablesDataBuilderInput(Settings); Settings.ActivePlayerDataBuilder.BuildData <AddressablesPlayerBuildResult>(context); var path = AssetDatabase.GUIDToAssetPath(m_AssetGUID); var obj = AssetDatabase.LoadAssetAtPath <GameObject>(path); obj.GetComponent <Transform>().SetPositionAndRotation(new Vector3(10, 10, 10), Quaternion.identity); #if UNITY_2018_3_OR_NEWER PrefabUtility.SavePrefabAsset(obj); #else EditorUtility.SetDirty(obj); #endif AssetDatabase.SaveAssets(); var tempPath = Path.GetDirectoryName(Application.dataPath) + "/Library/com.unity.addressables/StreamingAssetsCopy/" + PlatformMappingService.GetPlatform() + "/addressables_content_state.bin"; var modifiedEntries = ContentUpdateScript.GatherModifiedEntries(Settings, tempPath); Assert.IsNotNull(modifiedEntries); Assert.GreaterOrEqual(modifiedEntries.Count, 1); ContentUpdateScript.CreateContentUpdateGroup(Settings, modifiedEntries, "Content Update"); var contentGroup = Settings.FindGroup("Content Update"); Assert.IsNotNull(contentGroup); var movedEntry = contentGroup.GetAssetEntry(m_AssetGUID); Assert.AreSame(movedEntry, entry); Settings.RemoveGroup(group); }