Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.16.19] - 2021-04-08
- Fixed an issue where the group property of the AddressableAssetGroupSchema was not persisted, and could get lost when objects were reloaded

## [1.16.18] - 2021-03-23
- Fixed compile warning in Unity 2020.2+

## [1.16.17] - 2021-02-25
- Updated group rename logic to support engine AssetDatabase fix. Change should be transparent to users.
  • Loading branch information
Unity Technologies committed Apr 8, 2021
1 parent b8ec726 commit b122327
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 21 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ 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.16.19] - 2021-04-08
- Fixed an issue where the group property of the AddressableAssetGroupSchema was not persisted, and could get lost when objects were reloaded

## [1.16.18] - 2021-03-23
- Fixed compile warning in Unity 2020.2+

## [1.16.17] - 2021-02-25
- Updated group rename logic to support engine AssetDatabase fix. Change should be transparent to users.

## [1.16.16] - 2021-01-20
- Updated dependency versions for testcase fix

Expand Down
14 changes: 12 additions & 2 deletions Editor/Build/DataBuilders/BuildScriptVirtualMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
using System.Linq;
using System.Reflection;

#if UNITY_2019_3_OR_NEWER
using UnityEditor.Experimental;
#endif

namespace UnityEditor.AddressableAssets.Build.DataBuilders
{
/// <summary>
Expand Down Expand Up @@ -334,12 +338,18 @@ static string OutputLibraryPathForAsset(string a)
{
var guid = AssetDatabase.AssetPathToGUID(a);
var legacyPath = string.Format("Library/metadata/{0}{1}/{2}", guid[0], guid[1], guid);
#if UNITY_2020_2_OR_NEWER
#if UNITY_2020_2_OR_NEWER
var artifactID = Experimental.AssetDatabaseExperimental.ProduceArtifact(new ArtifactKey(new GUID(guid)));
if (Experimental.AssetDatabaseExperimental.GetArtifactPaths(artifactID, out var paths))
return Path.GetFullPath(paths[0]);
else
legacyPath = String.Empty;
#elif UNITY_2020_1_OR_NEWER
var hash = Experimental.AssetDatabaseExperimental.GetArtifactHash(guid);
if (Experimental.AssetDatabaseExperimental.GetArtifactPaths(hash, out var paths))
return Path.GetFullPath(paths[0]);
else
legacyPath = String.Empty; // legacy path is never valid in 2020.2+
legacyPath = String.Empty; // legacy path is never valid in 2020.1+
#elif UNITY_2019_3_OR_NEWER
if (IsAssetDatabaseV2Enabled()) // AssetDatabase V2 is optional in 2019.3 and 2019.4
{
Expand Down
39 changes: 26 additions & 13 deletions Editor/Settings/AddressableAssetGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@ public virtual string Name
}
set
{
string temp = value;
temp = temp.Replace('/', '-');
temp = temp.Replace('\\', '-');
if (temp != value)
string newName = value;
newName = newName.Replace('/', '-');
newName = newName.Replace('\\', '-');
if (newName != value)
Debug.Log("Group names cannot include '\\' or '/'. Replacing with '-'. " + m_GroupName);
if (m_GroupName != temp)
if (m_GroupName != newName)
{
string previousName = m_GroupName;
m_GroupName = temp;

string guid;
long localId;
Expand All @@ -79,27 +78,31 @@ public virtual string Name
{
var folder = Path.GetDirectoryName(path);
var extension = Path.GetExtension(path);
var newPath = $"{folder}/{m_GroupName}{extension}".Replace('\\', '/');
var newPath = $"{folder}/{newName}{extension}".Replace('\\', '/');
if (path != newPath)
{
var setPath = AssetDatabase.MoveAsset(path, newPath);
if (!string.IsNullOrEmpty(setPath) || !RenameSchemaAssets())
bool success = false;
if (string.IsNullOrEmpty(setPath))
{
name = m_GroupName = newName;
success = RenameSchemaAssets();
}

if (success == false)
{
//unable to rename group due to invalid file name
Debug.LogError("Rename of Group failed. " + setPath);
m_GroupName = previousName;
name = m_GroupName = previousName;
}
}
}

name = m_GroupName;
}
else
{
//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;
name = m_GroupName = newName;
}


SetDirty(AddressableAssetSettings.ModificationEvent.GroupRenamed, this, true, true);
}
Expand Down Expand Up @@ -145,7 +148,12 @@ public AddressableAssetGroupSchema AddSchema(AddressableAssetGroupSchema schema,
if (added != null)
{
added.Group = this;
if (m_Settings && m_Settings.IsPersisted)
EditorUtility.SetDirty(added);

SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaAdded, this, postEvent, true);

AssetDatabase.SaveAssets();
}
return added;
}
Expand All @@ -162,7 +170,12 @@ public AddressableAssetGroupSchema AddSchema(Type type, bool postEvent = true)
if (added != null)
{
added.Group = this;
if (m_Settings && m_Settings.IsPersisted)
EditorUtility.SetDirty(added);

SetDirty(AddressableAssetSettings.ModificationEvent.GroupSchemaAdded, this, postEvent, true);

AssetDatabase.SaveAssets();
}
return added;
}
Expand Down
6 changes: 4 additions & 2 deletions Tests/Editor/AddressableAssetSettingsLocatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public void WhenLocatorWithMultipeAssets_LocateWithSharedLabelReturnsMultipleLoc
AssertLocateResult(new AddressableAssetSettingsLocator(m_Settings), "label", null, GetPath("asset1.asset"), GetPath("asset2.asset"));
}

#if !(UNITY_2021_2_OR_NEWER)
[Test]
public void WhenLocatorWithAssetsThatMatchAssetsInFolderAndResources_LocateAllMatches()
{
Expand All @@ -162,6 +163,7 @@ public void WhenLocatorWithAssetsThatMatchAssetsInFolderAndResources_LocateAllMa
GetPath("asset1")
);
}
#endif

[Test]
public void WhenLocatorWithAssetsInMarkedFolder_LocateWithAssetReferenceSucceeds()
Expand Down Expand Up @@ -203,9 +205,9 @@ public void WhenLocatorWithAssetsInFolder_LocateWithFolderLabelSucceeds()
[Test]
public void WhenLocatorWithAssetsInFolderWithSimilarNames_LocateWithAssetKeySucceeds()
{
var folderGUID = CreateFolder("TestFolder", new string[] { "asset1", "asset", "asset1_more" });
var folderGUID = CreateFolder("TestFolder", new string[] { "asset1.asset", "asset.asset", "asset1_more.asset" });
m_Settings.CreateOrMoveEntry(folderGUID, m_Settings.DefaultGroup).address = "TF";
AssertLocateResult(new AddressableAssetSettingsLocator(m_Settings), "TF/asset1", null, GetPath("TestFolder/asset1"));
AssertLocateResult(new AddressableAssetSettingsLocator(m_Settings), "TF/asset1.asset", null, GetPath("TestFolder/asset1.asset"));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion Tests/Editor/AddressableAssetSettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public void AddressablesCleanAllCachedData_ClearsAllData()
public void DeletingAsset_DoesNotDeleteGroupWithSimilarName()
{
//Setup
const string groupName = "NewAsset";
const string groupName = "NewAsset.mat";
string assetPath = GetAssetPath(groupName);


Expand Down
1 change: 1 addition & 0 deletions Tests/Editor/GroupSchemaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void ModifyingGroupName_ChangesSchemaAssetPath()
// Set up
var group = Settings.CreateGroup("OldTestGroup", false, false, false, null);
var testSchema = group.AddSchema<CustomTestSchema>();
AssetDatabase.SaveAssets();

string testSchemaFilename = ObjectToFilename(testSchema);
Assert.IsTrue(testSchemaFilename.Contains("OldTestGroup"));
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.unity.addressables",
"displayName": "Addressables",
"version": "1.16.16",
"version": "1.16.19",
"unity": "2018.4",
"description": "The Addressable Asset System allows the developer to ask for an asset via its address. Once an asset (e.g. a prefab) is marked \"addressable\", it generates an address which can be called from anywhere. Wherever the asset resides (local or remote), the system will locate it and its dependencies, then return it.\n\nUse 'Window->Asset Management->Addressables' to begin working with the system.\n\nAddressables use asynchronous loading to support loading from any location with any collection of dependencies. Whether you have been using direct references, traditional asset bundles, or Resource folders, addressables provide a simpler way to make your game more dynamic. Addressables simultaneously opens up the world of asset bundles while managing all the complexity.\n\nFor usage samples, see github.com/Unity-Technologies/Addressables-Sample",
"keywords": [
Expand All @@ -20,9 +20,9 @@
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/Addressables.git",
"type": "git",
"revision": "c238142d6dd78f465fa645cb6b4671ab3472ec99"
"revision": "409be64ae2451fbde6a6e3e6fb1d6b7a1aa9a18c"
},
"upmCi": {
"footprint": "86de4a0cb6b2b8d4652802e07f1c5b0bea2d0426"
"footprint": "5090b8e50c1c58094e77ec5a07f4552bcfa05ae9"
}
}

0 comments on commit b122327

Please sign in to comment.