public void DedupeEntries_WhenGroupsHaveOverlappingAssetEntries_RemovesEntries() { const string guid = "0000"; const string address = "not/a/real/address"; AddressableAssetGroup group1 = m_Settings.CreateGroup("group1", false, false, true, null, new Type[] { }); AddressableAssetGroup group2 = m_Settings.CreateGroup("group2", false, false, true, null, new Type[] { }); //We're making 2 identical enteries. This is to simulate each group having it's own copy of an AA Entry that references the same object. //If we use the same object the call to AddAssetEntry won't give us the state we're looking for. AddressableAssetEntry entry = new AddressableAssetEntry(guid, address, group1, false); AddressableAssetEntry entry2 = new AddressableAssetEntry(guid, address, group2, false); group1.AddAssetEntry(entry); group2.AddAssetEntry(entry2); //Ensuring our setup is correct Assert.IsNotNull(group1.GetAssetEntry(guid)); Assert.IsNotNull(group2.GetAssetEntry(guid)); group1.DedupeEnteries(); //We setup our entry with group1 so it should retain its reference group2.DedupeEnteries(); //The entry was added to group2 afterwards and should lose its reference Assert.IsNotNull(group1.GetAssetEntry(guid)); Assert.IsNull(group2.GetAssetEntry(guid)); //Cleanup m_Settings.RemoveGroup(group1); m_Settings.RemoveGroup(group2); }
public void WhenIncludeLabelsOptionChanged_LocationsKeysAreSetCorrectly() { GenerateLocationListsTask.Input input = GenerateDefaultInput(); AddressableAssetGroup groupX = CreateGroupMappedToBundle(input, "X"); var schema = groupX.GetSchema <BundledAssetGroupSchema>(); var guid = CreateAddressablePrefab(input, "p1", groupX, "fileX"); groupX.GetAssetEntry(guid).SetLabel("LABEL1", true, true, true); input.AddressableAssetEntries = BuildAddressableAssetEntryList(input.Settings); schema.IncludeLabelsInCatalog = true; foreach (var l in GenerateLocationListsTask.ProcessInput(input).Locations) { if (l.Provider == typeof(BundledAssetProvider).FullName) { CollectionAssert.Contains(l.Keys, "LABEL1"); } } schema.IncludeLabelsInCatalog = false; foreach (var l in GenerateLocationListsTask.ProcessInput(input).Locations) { if (l.Provider == typeof(BundledAssetProvider).FullName) { CollectionAssert.DoesNotContain(l.Keys, "LABEL1"); } } }
static void CreateEntry(AddressableAssetSettings setting, AddressableAssetGroup group, string guid, string key, string label = null) { var entry = group.GetAssetEntry(guid); if (entry == null) { entry = setting.CreateOrMoveEntry(guid, group); entry.SetAddress(key); if (label != null) { setting.AddLabel(label, true); entry.SetLabel(label, true); } EditorUtility.SetDirty(setting); } else { string path = AssetDatabase.GUIDToAssetPath(guid); if (string.IsNullOrEmpty(path)) { setting.RemoveAssetEntry(guid); } else { if (key != entry.address) { entry.SetAddress(key); if (label != null) { setting.AddLabel(label, true); entry.SetLabel(label, true); } EditorUtility.SetDirty(setting); } } } }