Skip to content

Commit

Permalink
1.0.2-preview.2 - 2019/02/21
Browse files Browse the repository at this point in the history
@2018.2
  • Loading branch information
ErikMoczi committed Mar 3, 2019
1 parent eb4fbc3 commit 65c030b
Show file tree
Hide file tree
Showing 15 changed files with 218 additions and 102 deletions.
3 changes: 2 additions & 1 deletion package/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.0.2-preview.1] - 2019-02-15
## [1.0.2-preview.2] - 2019-02-15
- *BREAKING CODE CHANGES*
- to ease code navigation, we have added several layers of namespace to the code.
- any hardcoded profile path to com.unity.addressables (specifically LocalLoadPath, RemoteLoadPath, etc) should use UnityEngine.AddressableAssets.Addressables.RuntimePath instead.
Expand All @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- We have removed attribute AssetReferenceTypeRestriction as it is cleaner to enforce type via generics
- Attribute AssetReferenceLabelRestriction is renamed to AssetReferenceUILabelRestriction and must be surrounded by #if UNITY_EDITOR in your game code, to enforce it's editor-only capability
- Modifications to IResourceProvider API.
- Removed PreloadDependencies API. Instead use DownloadDependencies
- Content Update calculation has changed, this will invalide previously generated addressables_content_state.bin files.
- Some types for content update were made private as a result of the above change.
- Moved all of the Resource Manager package to be contained within Addressables (no longer a stand alone package). No code change implications.
Expand Down
2 changes: 1 addition & 1 deletion package/Editor/Build/DataBuilders/BuildScriptPackedMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static void CreateCatalog(AddressableAssetSettings aaSettings, ContentCatalogDat
remoteBuildFolder == AddressableAssetProfileSettings.undefinedEntryValue ||
remoteLoadFolder == AddressableAssetProfileSettings.undefinedEntryValue)
{
Addressables.LogError("Remote Build and/or Load paths are not set. Cannot create remote catalog. '" + remoteBuildFolder + "', '" + remoteLoadFolder + "'");
Addressables.LogError("Remote Build and/or Load paths are not set on the main AddressableAssetSettings asset, but 'Build Remote Catalog' is true. Cannot create remote catalog. In the inspector for any group, double click the 'Addressable Asset Settings' object to begin inspecting it. '" + remoteBuildFolder + "', '" + remoteLoadFolder + "'");
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions package/Editor/Diagnostics/GUI/EventViewerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ void DrawToolBar(EventDataPlayerSession session)
m_Record = GUILayout.Toggle(m_Record, "Record", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false));

if (GUILayout.Button("Clear", EditorStyles.toolbarButton))
{
session.Clear();
if (m_GraphList != null)
m_GraphList.Reload();
}
if (GUILayout.Button("Load", EditorStyles.toolbarButton))
EditorUtility.DisplayDialog("Feature not implemented", "Saving and loading profile data is not yet supported", "Close");
if (GUILayout.Button("Save", EditorStyles.toolbarButton))
Expand Down
6 changes: 4 additions & 2 deletions package/Editor/GUI/AddressableAssetsSettingsGroupTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,13 @@ protected override void ContextClickedItem(int id)
{
if (isGroup)
{
menu.AddItem(new GUIContent("Remove Group(s)"), false, RemoveGroup, selectedNodes);
var group = selectedNodes.First().group;
if (!group.IsDefaultGroup())
menu.AddItem(new GUIContent("Remove Group(s)"), false, RemoveGroup, selectedNodes);

if (selectedNodes.Count == 1)
{
if (!selectedNodes.First().group.Default)
if (!group.IsDefaultGroup() && group.CanBeSetAsDefault())
menu.AddItem(new GUIContent("Set as Default"), false, SetGroupAsDefault, selectedNodes);
menu.AddItem(new GUIContent("Inspect Group Settings"), false, GoToGroupAsset, selectedNodes);
}
Expand Down
18 changes: 18 additions & 0 deletions package/Editor/Settings/AddressableAssetGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,5 +496,23 @@ internal void RemoveAssetEntries(IEnumerable<AddressableAssetEntry> removeEntrie

SetDirty(AddressableAssetSettings.ModificationEvent.EntryRemoved, removeEntries.ToArray(), postEvent);
}

/// <summary>
/// Check to see if a group is the Default Group.
/// </summary>
/// <returns></returns>
public bool IsDefaultGroup()
{
return Guid == m_Settings.DefaultGroup.Guid;
}

/// <summary>
/// Check if a group has the appropriate schemas and attributes that the Default Group requires.
/// </summary>
/// <returns></returns>
public bool CanBeSetAsDefault()
{
return !m_ReadOnly && HasSchema<BundledAssetGroupSchema>();
}
}
}
130 changes: 70 additions & 60 deletions package/Editor/Settings/AddressableAssetSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AddressableAssetSettings : ScriptableObject
static void RegisterWithAssetPostProcessor()
{
//if the Library folder has been deleted, this will be null and it will have to be set on the first access of the settings object
if(AddressableAssetSettingsDefaultObject.Settings != null)
if (AddressableAssetSettingsDefaultObject.Settings != null)
AddressablesAssetPostProcessor.OnPostProcess = AddressableAssetSettingsDefaultObject.Settings.OnPostprocessAllAssets;
}
/// <summary>
Expand Down Expand Up @@ -172,7 +172,7 @@ public string GroupSchemaFolder
/// Returns whether this settings object is persisted to an asset.
/// </summary>
public bool IsPersisted { get { return !m_IsTemporary; } }

[SerializeField]
bool m_BuildRemoteCatalog = true;

Expand All @@ -184,7 +184,7 @@ public bool BuildRemoteCatalog
get { return m_BuildRemoteCatalog; }
set { m_BuildRemoteCatalog = value; }
}

[SerializeField]
ProfileValueReference m_RemoteCatalogBuildPath;
/// <summary>
Expand Down Expand Up @@ -249,13 +249,13 @@ public Hash128 currentHash
return (m_CachedHash = HashingMethods.Calculate(stream).ToHash128());
}
}

internal void DataBuilderCompleted(IDataBuilder builder, IDataBuilderResult result)
{
if (OnDataBuilderComplete != null)
OnDataBuilderComplete(this, builder, result);
}

/// <summary>
/// Create an AssetReference object. If the asset is not already addressable, it will be added.
/// </summary>
Expand Down Expand Up @@ -702,9 +702,9 @@ public bool RemoveAssetEntry(string guid, bool postEvent = true)
}
return false;
}

void OnEnable()
{
{
profileSettings.OnAfterDeserialize(this);
buildSettings.OnAfterDeserialize(this);
Validate();
Expand Down Expand Up @@ -738,7 +738,7 @@ void Validate()
m_DataBuilders.Add(CreateScriptAsset<BuildScriptPackedPlayMode>());
m_DataBuilders.Add(CreateScriptAsset<BuildScriptPackedMode>());
}
if(m_DataBuilders.Find(s=>s.GetType() == typeof(BuildScriptPackedPlayMode)) == null)
if (m_DataBuilders.Find(s => s.GetType() == typeof(BuildScriptPackedPlayMode)) == null)
m_DataBuilders.Add(CreateScriptAsset<BuildScriptPackedPlayMode>());

if (ActivePlayerDataBuilder != null && !ActivePlayerDataBuilder.CanBuildData<AddressablesPlayerBuildResult>())
Expand All @@ -749,7 +749,7 @@ void Validate()
profileSettings.Validate(this);
buildSettings.Validate(this);
}

T CreateScriptAsset<T>() where T : ScriptableObject
{
var script = CreateInstance<T>();
Expand Down Expand Up @@ -792,16 +792,8 @@ public static AddressableAssetSettings Create(string configFolder, string config

if (createDefaultGroups)
{
var playerData = aa.CreateGroup(PlayerDataGroupName, false, false, false, null, typeof(PlayerDataGroupSchema));
var resourceEntry = aa.CreateOrMoveEntry(AddressableAssetEntry.ResourcesName, playerData);
resourceEntry.IsInResources = true;
aa.CreateOrMoveEntry(AddressableAssetEntry.EditorSceneListName, playerData);

var localGroup = aa.CreateGroup(DefaultLocalGroupName, true, false, false, null, typeof(ContentUpdateGroupSchema), typeof(BundledAssetGroupSchema));
var schema = localGroup.GetSchema<BundledAssetGroupSchema>();
schema.BuildPath.SetVariableByName(aa, kLocalBuildPath);
schema.LoadPath.SetVariableByName(aa, kLocalLoadPath);
schema.BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackTogether;
CreateBuiltInData(aa);
CreateDefaultGroup(aa);
}

if (isPersisted)
Expand All @@ -810,6 +802,7 @@ public static AddressableAssetSettings Create(string configFolder, string config
return aa;
}


/// <summary>
/// Adds a named set of schema types for use in the editor GUI.
/// </summary>
Expand Down Expand Up @@ -883,48 +876,62 @@ public AddressableAssetGroup DefaultGroup
{
get
{
AddressableAssetGroup group = null;
if (string.IsNullOrEmpty(m_DefaultGroup))
group = groups.Find(s => s.CanBeSetAsDefault());
else
{
//set to the first non readonly group if possible
foreach (var g in groups)
{
if (g != null && !g.ReadOnly)
{
m_DefaultGroup = g.Guid;
break;
}
}
if (string.IsNullOrEmpty(m_DefaultGroup))
group = groups.Find(s => s.Guid == m_DefaultGroup);
if (group == null || !group.CanBeSetAsDefault())
{
Addressables.LogError("Attempting to access Default Addressables group but no valid group is available");
return null;
group = groups.Find(s => s.CanBeSetAsDefault());
if (group != null)
m_DefaultGroup = group.Guid;
}
}
var group = groups.Find(s => s.Guid == m_DefaultGroup);
if(group == null)

if (group == null)
{
foreach(var g in groups)
{
if (!g.ReadOnly)
{
group = g;
break;
}
}
if(group == null)
{
Debug.LogWarning("Addressable assets must have at least one group that is not read-only to be default, creating new group");
group = CreateGroup("New Group", true, false, true, null, typeof(BundledAssetGroupSchema));
}
Addressables.LogWarning("A valid default group could not be found. One will be created.");
group = CreateDefaultGroup(this);
}

return group;
}
set
{
m_DefaultGroup = value.Guid;
if (value == null)
Addressables.LogError("Unable to set null as the Default Group. Default Groups must contain a BundledAssetGroupSchema and " +
"not be ReadOnly.");

else if (!value.CanBeSetAsDefault())
Addressables.LogError("Unable to set " + value.Name + " as the Default Group. Default Groups must contain a BundledAssetGroupSchema and " +
"not be ReadOnly.");
else
m_DefaultGroup = value.Guid;
}
}

private static AddressableAssetGroup CreateBuiltInData(AddressableAssetSettings aa)
{
var playerData = aa.CreateGroup(PlayerDataGroupName, false, false, false, null, typeof(PlayerDataGroupSchema));
var resourceEntry = aa.CreateOrMoveEntry(AddressableAssetEntry.ResourcesName, playerData);
resourceEntry.IsInResources = true;
aa.CreateOrMoveEntry(AddressableAssetEntry.EditorSceneListName, playerData);
return playerData;
}

private static AddressableAssetGroup CreateDefaultGroup(AddressableAssetSettings aa)
{
var localGroup = aa.CreateGroup(DefaultLocalGroupName, true, false, false, null, typeof(ContentUpdateGroupSchema), typeof(BundledAssetGroupSchema));
var schema = localGroup.GetSchema<BundledAssetGroupSchema>();
schema.BuildPath.SetVariableByName(aa, kLocalBuildPath);
schema.LoadPath.SetVariableByName(aa, kLocalLoadPath);
schema.BundleMode = BundledAssetGroupSchema.BundlePackingMode.PackTogether;
aa.m_DefaultGroup = localGroup.Guid;
return localGroup;
}

AddressableAssetEntry CreateEntry(string guid, string address, AddressableAssetGroup parent, bool readOnly, bool postEvent = true)
{
var entry = new AddressableAssetEntry(guid, address, parent, readOnly);
Expand Down Expand Up @@ -1062,15 +1069,15 @@ public void MoveEntry(AddressableAssetEntry entry, AddressableAssetGroup targetP
{
if (targetParent == null || entry == null)
return;

entry.ReadOnly = readOnly;

if (entry.parentGroup != null && entry.parentGroup != targetParent)
entry.parentGroup.RemoveAssetEntry(entry, postEvent);

targetParent.AddAssetEntry(entry, postEvent);
}

/// <summary>
/// Create a new entry, or if one exists in a different group, move it into the new group.
/// </summary>
Expand Down Expand Up @@ -1100,7 +1107,7 @@ public AddressableAssetEntry CreateOrMoveEntry(string guid, AddressableAssetGrou
{
entry = CreateEntry(guid, guid, targetParent, true, postEvent);
}

targetParent.AddAssetEntry(entry, postEvent);
}

Expand Down Expand Up @@ -1150,15 +1157,12 @@ public AddressableAssetGroup CreateGroup(string groupName, bool setAsDefaultGrou
var group = CreateInstance<AddressableAssetGroup>();
group.Initialize(this, validName, GUID.Generate().ToString(), readOnly);

groups.Add(group);
if (IsPersisted)
{
if (!Directory.Exists(GroupFolder))
Directory.CreateDirectory(GroupFolder);
AssetDatabase.CreateAsset(group, GroupFolder + "/" + group.Name + ".asset");
}
if (setAsDefaultGroup)
DefaultGroup = group;
if (schemasToCopy != null)
{
foreach (var s in schemasToCopy)
Expand All @@ -1167,6 +1171,10 @@ public AddressableAssetGroup CreateGroup(string groupName, bool setAsDefaultGrou
foreach (var t in types)
group.AddSchema(t);

groups.Add(group);

if (setAsDefaultGroup)
DefaultGroup = group;
SetDirty(ModificationEvent.GroupAdded, group, postEvent);
return group;
}
Expand All @@ -1175,7 +1183,7 @@ internal string FindUniqueGroupName(string potentialName)
{
var cleanedName = potentialName.Replace('/', '-');
cleanedName = cleanedName.Replace('\\', '-');
if(cleanedName != potentialName)
if (cleanedName != potentialName)
Addressables.Log("Group names cannot include '\\' or '/'. Replacing with '-'. " + cleanedName);
var validName = cleanedName;
int index = 1;
Expand Down Expand Up @@ -1262,7 +1270,7 @@ internal void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAs
if (typeof(AddressableAssetGroup).IsAssignableFrom(assetType))
{
AddressableAssetGroup group = aa.FindGroup(Path.GetFileNameWithoutExtension(str));
if(group != null)
if (group != null)
group.DedupeEnteries();
}

Expand Down Expand Up @@ -1290,7 +1298,7 @@ internal void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAs
{
modified = true;
}

}

foreach (string str in deletedAssets)
Expand Down Expand Up @@ -1400,12 +1408,14 @@ public static void BuildPlayerContent()
Debug.LogException(e);
}
}

var buildContext = new AddressablesBuildDataBuilderContext(settings,
BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget),
EditorUserBuildSettings.activeBuildTarget, EditorUserBuildSettings.development,
ProjectConfigData.postProfilerEvents, settings.PlayerBuildVersion);
settings.ActivePlayerDataBuilder.BuildData<AddressablesPlayerBuildResult>(buildContext);
var result = settings.ActivePlayerDataBuilder.BuildData<AddressablesPlayerBuildResult>(buildContext);
if(BuildScript.buildCompleted != null)
BuildScript.buildCompleted(result);
AssetDatabase.Refresh();
}

Expand Down
Loading

0 comments on commit 65c030b

Please sign in to comment.