Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.1.5] - 2019-07-15
 - Fixed scenario where scene unload destroys instantiated objects in different scenes.
 - Cleaned up SetDirty logic to remove excessive dirtying of assets.
  • Loading branch information
Unity Technologies committed Jul 14, 2019
1 parent c624c36 commit 20bb7ae
Show file tree
Hide file tree
Showing 18 changed files with 163 additions and 77 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.1.5] - 2019-07-15
- Fixed scenario where scene unload destroys instantiated objects in different scenes.
- Cleaned up SetDirty logic to remove excessive dirtying of assets.

## [1.1.4-preview] - 2019-06-19
- Fixed an issue where Editor only types were being added to the build.

Expand Down
2 changes: 1 addition & 1 deletion Editor/GUI/AddressableAssetSettingsInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public override void OnInspectorGUI()
{
var profile = m_AasTarget.profileSettings.profiles[m_CurrentProfileIndex];
profile.profileName = newName;
m_AasTarget.SetDirty(AddressableAssetSettings.ModificationEvent.ProfileModified, profile.id, true);
m_AasTarget.SetDirty(AddressableAssetSettings.ModificationEvent.ProfileModified, profile.id, true, true);
}
}
}
Expand Down
46 changes: 31 additions & 15 deletions Editor/GUI/AddressableAssetsSettingsGroupTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -852,50 +852,57 @@ protected void RemoveGroup(object context)
if (EditorUtility.DisplayDialog("Delete selected groups?", "Are you sure you want to delete the selected groups?\n\nYou cannot undo this action.", "Yes", "No"))
{
List<AssetEntryTreeViewItem> selectedNodes = context as List<AssetEntryTreeViewItem>;
if (selectedNodes == null)
if (selectedNodes == null || selectedNodes.Count < 1)
return;
var groups = new List<AddressableAssetGroup>();
foreach (var item in selectedNodes)
{
m_Editor.settings.RemoveGroupInternal(item.group, true, false);
groups.Add(item.group);
}
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.GroupRemoved, groups, true);
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.GroupRemoved, groups, true, true);
}
}

protected void SimplifyAddresses(object context)
{
List<AssetEntryTreeViewItem> selectedNodes = context as List<AssetEntryTreeViewItem>;
if (selectedNodes == null)
if (selectedNodes == null || selectedNodes.Count < 1)
return;
var entries = new List<AddressableAssetEntry>();

HashSet<AddressableAssetGroup> modifiedGroups = new HashSet<AddressableAssetGroup>();
foreach (var item in selectedNodes)
{
item.entry.SetAddress(Path.GetFileNameWithoutExtension(item.entry.address), false);
entries.Add(item.entry);
modifiedGroups.Add(item.entry.parentGroup);
}
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entries, true);
foreach (var g in modifiedGroups)
g.SetDirty(AddressableAssetSettings.ModificationEvent.EntryModified, entries, false, true);
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryModified, entries, true, false);
}

protected void RemoveEntry(object context)
{
if (EditorUtility.DisplayDialog("Delete selected entries?", "Are you sure you want to delete the selected entries?\n\nYou cannot undo this action.", "Yes", "No"))
{
List<AssetEntryTreeViewItem> selectedNodes = context as List<AssetEntryTreeViewItem>;
if (selectedNodes == null)
if (selectedNodes == null || selectedNodes.Count < 1)
return;
var entries = new List<AddressableAssetEntry>();
HashSet<AddressableAssetGroup> modifiedGroups = new HashSet<AddressableAssetGroup>();
foreach (var item in selectedNodes)
{
if (item.entry != null)
{
m_Editor.settings.RemoveAssetEntry(item.entry.guid, false);
entries.Add(item.entry);
modifiedGroups.Add(item.entry.parentGroup);
}
}
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryRemoved, entries, true);
foreach (var g in modifiedGroups)
g.SetDirty(AddressableAssetSettings.ModificationEvent.EntryModified, entries, false, true);
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryRemoved, entries, true, false);
}
}

Expand Down Expand Up @@ -1036,13 +1043,17 @@ protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
if (canMarkNonResources)
{
var entries = new List<AddressableAssetEntry>();
var modifiedGroups = new HashSet<AddressableAssetGroup>();
foreach (var p in nonResourcePaths)
{
entries.Add(m_Editor.settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(p), parent, false, false));
var e = m_Editor.settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(p), parent, false, false);
entries.Add(e);
modifiedGroups.Add(e.parentGroup);
}
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entries, true);
foreach (var g in modifiedGroups)
g.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entries, false, true);
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entries, true, false);
}

}
}
}
Expand Down Expand Up @@ -1072,7 +1083,7 @@ protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
else
m_Editor.settings.groups.Insert(args.insertAtIndex, group);

m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.GroupMoved, m_Editor.settings.groups, true);
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.GroupMoved, m_Editor.settings.groups, true, true);
Reload();
}
else
Expand All @@ -1092,11 +1103,16 @@ protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
else
{
var entries = new List<AddressableAssetEntry>();
var modifiedGroups = new HashSet<AddressableAssetGroup>();
foreach (var node in draggedNodes)
entries.Add(m_Editor.settings.CreateOrMoveEntry(node.entry.guid, parent, false,
false));
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved,
entries, true);
{
var e = m_Editor.settings.CreateOrMoveEntry(node.entry.guid, parent, false, false);
entries.Add(e);
modifiedGroups.Add(e.parentGroup);
}
foreach (var g in modifiedGroups)
g.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entries, false, true);
m_Editor.settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entries, true, false);
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions Editor/GUI/AssetInspectorGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ static void SetAaEntry(AddressableAssetSettings aaSettings, Object[] targets, bo
//if (create || EditorUtility.DisplayDialog("Remove Addressable Asset Entries", "Do you want to remove Addressable Asset entries for " + targets.Length + " items?", "Yes", "Cancel"))
{
var entriesAdded = new List<AddressableAssetEntry>();

var modifiedGroups = new HashSet<AddressableAssetGroup>();
foreach (var t in targets)
{
if (AddressableAssetUtility.GetPathAndGUIDFromTarget(t, out path, ref guid))
{
if (create)
{
if (AddressableAssetUtility.IsInResources(path))
AddressableAssetUtility.SafeMoveResourcesToGroup(aaSettings, aaSettings.DefaultGroup, new List<string> {path});
AddressableAssetUtility.SafeMoveResourcesToGroup(aaSettings, aaSettings.DefaultGroup, new List<string> { path });
else
entriesAdded.Add(aaSettings.CreateOrMoveEntry(guid, aaSettings.DefaultGroup, false, false));
{
var e = aaSettings.CreateOrMoveEntry(guid, aaSettings.DefaultGroup, false, false);
entriesAdded.Add(e);
modifiedGroups.Add(e.parentGroup);
}
}
else
aaSettings.RemoveAssetEntry(guid);
Expand All @@ -48,7 +52,9 @@ static void SetAaEntry(AddressableAssetSettings aaSettings, Object[] targets, bo

if (create)
{
aaSettings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entriesAdded, true);
foreach (var g in modifiedGroups)
g.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entriesAdded, false, true);
aaSettings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entriesAdded, true, false);
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion Editor/GUI/ContentUpdatePreviewWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ namespace UnityEditor.AddressableAssets.GUI
{
class ContentUpdatePreviewWindow : EditorWindow
{
internal static bool PrepareForContentUpdate(AddressableAssetSettings settings, string buildPath)
/// <summary>
/// Opens ContentUpdatePreviewWindow.
/// </summary>
/// <param name="settings"></param>
/// <param name="buildPath"></param>
/// <returns>True if successful; false if otherwise (failed to get modified entries).</returns>
public static bool PrepareForContentUpdate(AddressableAssetSettings settings, string buildPath)
{
var modifiedEntries = ContentUpdateScript.GatherModifiedEntries(settings, buildPath);
if (modifiedEntries == null)
Expand Down
4 changes: 2 additions & 2 deletions Editor/HostingServices/HostingServicesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public IHostingService AddHostingService(Type serviceType, string name)
m_Settings.profileSettings.RegisterProfileStringEvaluationFunc(svc.EvaluateProfileString);

m_HostingServiceInfoMap.Add(svc, info);
m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.HostingServicesManagerModified, this, true);
m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.HostingServicesManagerModified, this, true, true);

m_NextInstanceId++;
return svc;
Expand All @@ -252,7 +252,7 @@ public void RemoveHostingService(IHostingService svc)
svc.StopHostingService();
m_Settings.profileSettings.UnregisterProfileStringEvaluationFunc(svc.EvaluateProfileString);
m_HostingServiceInfoMap.Remove(svc);
m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.HostingServicesManagerModified, this, true);
m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.HostingServicesManagerModified, this, true, true);
}

/// <summary>
Expand Down
11 changes: 9 additions & 2 deletions Editor/Settings/AddressableAssetBuildSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ public bool cleanupStreamingAssetsAfterBuilds
public bool LogResourceManagerExceptions
{
get { return m_LogResourceManagerExceptions; }
set { m_LogResourceManagerExceptions = value; }
set
{
if (m_LogResourceManagerExceptions != value)
{
m_LogResourceManagerExceptions = value;
SetDirty();
}
}
}

/// <summary>
Expand Down Expand Up @@ -88,7 +95,7 @@ internal void SerializeForHash(BinaryFormatter formatter, Stream stream)
void SetDirty()
{
if (m_Settings != null)
m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.BuildSettingsChanged, this, true);
m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.BuildSettingsChanged, this, true, false);
}
internal void OnAfterDeserialize(AddressableAssetSettings settings)
{
Expand Down
2 changes: 1 addition & 1 deletion Editor/Settings/AddressableAssetEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ internal void SerializeForHash(BinaryFormatter formatter, Stream stream)
internal void SetDirty(AddressableAssetSettings.ModificationEvent e, object o, bool postEvent)
{
if (parentGroup != null)
parentGroup.SetDirty(e, o, postEvent);
parentGroup.SetDirty(e, o, postEvent, true);
}

/// <summary>
Expand Down
29 changes: 15 additions & 14 deletions Editor/Settings/AddressableAssetGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public virtual string Name
//this isn't a valid asset, which means it wasn't persisted, so just set the object name to the desired display name.
name = m_GroupName;
}
SetDirty(AddressableAssetSettings.ModificationEvent.GroupRenamed, this, true);
SetDirty(AddressableAssetSettings.ModificationEvent.GroupRenamed, this, true, true);
}
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ public AddressableAssetGroupSchema AddSchema(AddressableAssetGroupSchema schema,
if (added != null)
{
added.Group = this;
SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaAdded, this, postEvent);
SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaAdded, this, postEvent, true);
}
return added;
}
Expand All @@ -149,7 +149,7 @@ public AddressableAssetGroupSchema AddSchema(Type type, bool postEvent = true)
if (added != null)
{
added.Group = this;
SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaAdded, this, postEvent);
SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaAdded, this, postEvent, true);
}
return added;
}
Expand All @@ -176,7 +176,7 @@ public bool RemoveSchema(Type type, bool postEvent = true)
if (!m_SchemaSet.RemoveSchema(type))
return false;

SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaRemoved, this, postEvent);
SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaRemoved, this, postEvent, true);
return true;
}

Expand Down Expand Up @@ -229,7 +229,7 @@ public bool HasSchema<TSchema>()
public void ClearSchemas(bool deleteAssets, bool postEvent = true)
{
m_SchemaSet.ClearSchemas(deleteAssets);
SetDirty(AddressableAssetSettings.ModificationEvent.GroupRemoved, this, postEvent);
SetDirty(AddressableAssetSettings.ModificationEvent.GroupRemoved, this, postEvent, true);
}

/// <summary>
Expand Down Expand Up @@ -409,8 +409,8 @@ internal void DedupeEnteries()
removeEntries.Add(e);
}
}

RemoveAssetEntries(removeEntries);
if(removeEntries.Count > 0)
RemoveAssetEntries(removeEntries);
}

internal void Initialize(AddressableAssetSettings settings, string groupName, string guid, bool readOnly)
Expand Down Expand Up @@ -440,7 +440,7 @@ internal void AddAssetEntry(AddressableAssetEntry e, bool postEvent = true)
e.IsSubAsset = false;
e.parentGroup = this;
m_EntryMap[e.guid] = e;
SetDirty(AddressableAssetSettings.ModificationEvent.EntryAdded, e, postEvent);
SetDirty(AddressableAssetSettings.ModificationEvent.EntryAdded, e, postEvent, true);
}

/// <summary>
Expand All @@ -461,13 +461,14 @@ public virtual AddressableAssetEntry GetAssetEntry(string guid)
/// <param name="modificationEvent">The event type that is changed.</param>
/// <param name="eventData">The object data that corresponds to the event.</param>
/// <param name="postEvent">If true, the event is propagated to callbacks.</param>
public void SetDirty(AddressableAssetSettings.ModificationEvent modificationEvent, object eventData, bool postEvent)
/// <param name="groupModified">If true, the group asset will be marked as dirty.</param>
public void SetDirty(AddressableAssetSettings.ModificationEvent modificationEvent, object eventData, bool postEvent, bool groupModified = false)
{
if (Settings != null)
{
if (Settings.IsPersisted && this != null)
if (groupModified && Settings.IsPersisted && this != null)
EditorUtility.SetDirty(this);
Settings.SetDirty(modificationEvent, eventData, postEvent);
Settings.SetDirty(modificationEvent, eventData, postEvent, false);
}
}

Expand All @@ -480,7 +481,7 @@ public void RemoveAssetEntry(AddressableAssetEntry entry, bool postEvent = true)
{
m_EntryMap.Remove(entry.guid);
entry.parentGroup = null;
SetDirty(AddressableAssetSettings.ModificationEvent.EntryRemoved, entry, postEvent);
SetDirty(AddressableAssetSettings.ModificationEvent.EntryRemoved, entry, postEvent, true);
}

internal void RemoveAssetEntries(IEnumerable<AddressableAssetEntry> removeEntries, bool postEvent = true)
Expand All @@ -490,8 +491,8 @@ internal void RemoveAssetEntries(IEnumerable<AddressableAssetEntry> removeEntrie
m_EntryMap.Remove(entry.guid);
entry.parentGroup = null;
}

SetDirty(AddressableAssetSettings.ModificationEvent.EntryRemoved, removeEntries.ToArray(), postEvent);
if(removeEntries.Count() > 0)
SetDirty(AddressableAssetSettings.ModificationEvent.EntryRemoved, removeEntries.ToArray(), postEvent, true);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Editor/Settings/AddressableAssetGroupSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void SetDirty(bool postEvent)
if (m_Group.Settings != null && m_Group.Settings.IsPersisted)
EditorUtility.SetDirty(this);
if (m_Group != null)
m_Group.SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaModified, this, postEvent);
m_Group.SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaModified, this, postEvent, false);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Editor/Settings/AddressableAssetGroupTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void SetDirty(AddressableAssetSettings.ModificationEvent modificationEven
{
if (Settings.IsPersisted && this != null)
EditorUtility.SetDirty(this);
Settings.SetDirty(modificationEvent, eventData, postEvent);
Settings.SetDirty(modificationEvent, eventData, postEvent, false);
}
}
}
Expand Down
Loading

0 comments on commit 20bb7ae

Please sign in to comment.