Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.19.11] - 2021-10-23
- Fixed issue with missing reference exception when using addressables where content has not been built.
- Added warning that LZMA compression is not available for WebGL AssetBundles.
- Fixed issue were getting a Group Template fails where the project name or parent directory ended in "Assets".
- Fixed issue where option to build Addressables when building a Player where displayed for unsupported editor versions.
- Fixed issue where hosting services filters ip addresses when entering playmode and no services are in use
- Fixed "Editor Hosted" LoadPath, to work with active local Editor hosting service
- Fixed error where creating new groups would lead to errors if the default build and load path variables were not present in one's profile settings.
- Modified the behavior of AssetReference.editorAsset and AssetReference.SetEditorAsset to be more consistent and intuitive
- Fixed issue where upgrading from versions that didn't have ProfileGroupTypes was causing issues during builds.
  • Loading branch information
Unity Technologies committed Oct 23, 2021
1 parent 0d35526 commit 966984d
Show file tree
Hide file tree
Showing 27 changed files with 814 additions and 106 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ 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.19.11] - 2021-10-23
- Fixed issue with missing reference exception when using addressables where content has not been built.
- Added warning that LZMA compression is not available for WebGL AssetBundles.
- Fixed issue were getting a Group Template fails where the project name or parent directory ended in "Assets".
- Fixed issue where option to build Addressables when building a Player where displayed for unsupported editor versions.
- Fixed issue where hosting services filters ip addresses when entering playmode and no services are in use
- Fixed "Editor Hosted" LoadPath, to work with active local Editor hosting service
- Fixed error where creating new groups would lead to errors if the default build and load path variables were not present in one's profile settings.
- Modified the behavior of AssetReference.editorAsset and AssetReference.SetEditorAsset to be more consistent and intuitive
- Fixed issue where upgrading from versions that didn't have ProfileGroupTypes was causing issues during builds.

## [1.19.9] - 2021-09-30
- Fixing a compile error on platforms where the Caching API is stripped.
- Updating ScriptableBuildPipeline dependency
Expand Down Expand Up @@ -55,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- UnloadSceneAsync APIs with exposed UnloadSceneOptions parameter
- Addressables.CleanBundleCache
- New parameter for Addressables.UpdateCatalogs to auto clean the bundle cache
- ProfileGroupType introduces a new workflow of grouping profile variables in the Addressables Profiles window, otherwise known as path pairs.

## [1.18.15] - 2021-07-26
- Improved Addressables inspector for Assets.
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/LoadingAddressableAssets.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ When you call [InstantiateAsync] you have the same options as the [Object.Instan

Because the Addressables system uses reference counting to determine whether an asset is in use, you must release every asset that you load or instantiate when you are done with it. See [Memory Management] for more information.

When you unload a Scene, implicit assets in the Scene are not automatically unloaded. You must call [Resources.UnloadUnusedAssets] or [UnloadAsset] to free these assets. Note that the Unity runtime automatically calls `UnloadUnusedAssets` when you load a Scene using the
When you unload a Scene, implicit assets in the Scene are not automatically unloaded. You must call [Resources.UnloadUnusedAssets] or [UnloadAsset] to free these assets. Note that the Unity runtime automatically calls `UnloadUnusedAssets` when you load a Scene using the [LoadSceneMode.Single] mode.

## Using Addressables in a Scene

Expand Down
9 changes: 6 additions & 3 deletions Editor/Build/AddressablesBuildScriptHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ static void Init()

static void OnEditorPlayModeChanged(PlayModeStateChange state)
{
var settings = AddressableAssetSettingsDefaultObject.Settings;
if (settings == null)
return;
if (state == PlayModeStateChange.ExitingEditMode)
{
var settings = AddressableAssetSettingsDefaultObject.Settings;
if (settings == null)
return;
if (settings.ActivePlayModeDataBuilder == null)
{
var err = "Active play mode build script is null.";
Expand Down Expand Up @@ -66,8 +66,11 @@ static void OnEditorPlayModeChanged(PlayModeStateChange state)
if (BuildScript.buildCompleted != null)
BuildScript.buildCompleted(res);
settings.DataBuilderCompleted(settings.ActivePlayModeDataBuilder, res);
settings.HostingServicesManager.exitingEditMode = true;
}
}
else
settings.HostingServicesManager.exitingEditMode = false;
}
}
}
6 changes: 5 additions & 1 deletion Editor/GUI/AddressableAssetSettingsInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ void OnEnable()
#if UNITY_2019_4_OR_NEWER
GUIContent m_CCDEnabled = new GUIContent("Enable Experimental CCD Features", "If enabled, will unlock experimental CCD features");
#endif
#if UNITY_2021_2_OR_NEWER
GUIContent m_BuildAddressablesWithPlayerBuild =
new GUIContent("Build Addressables on Player Build", "Determines if a new Addressables build will be built with a Player Build.");

#endif

public override void OnInspectorGUI()
{
m_QueuedChanges.Clear();
Expand Down Expand Up @@ -276,6 +278,7 @@ public override void OnInspectorGUI()
m_BuildFoldout = EditorGUILayout.Foldout(m_BuildFoldout, "Build");
if (m_BuildFoldout)
{
#if UNITY_2021_2_OR_NEWER
int index = (int) m_AasTarget.BuildAddressablesWithPlayerBuild;
int newIndex = EditorGUILayout.Popup(m_BuildAddressablesWithPlayerBuild, index, new[]
{
Expand All @@ -293,6 +296,7 @@ public override void OnInspectorGUI()
EditorGUILayout.TextField(" ", enabled ? "Enabled" : "Disabled");
}
}
#endif

bool ignoreUnsupportedFilesInBuild = EditorGUILayout.Toggle(m_IgnoreUnsupportedFilesInBuild, m_AasTarget.IgnoreUnsupportedFilesInBuild);
if (ignoreUnsupportedFilesInBuild != m_AasTarget.IgnoreUnsupportedFilesInBuild)
Expand Down
23 changes: 19 additions & 4 deletions Editor/GUI/ProfileDataSourceDropdownWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ internal enum CCDDropdownState { Bucket, Badge };
internal string m_BucketId;
internal string m_BucketName;
internal ProfileGroupType m_Bucket;
internal bool m_isRefreshingCCDDataSources;

private ProfileDataSourceSettings m_ProfileDataSource;

internal ProfileDataSourceSettings dataSourceSettings
{
get { return ProfileDataSourceSettings.GetSettings(); }
get
{
if (m_ProfileDataSource == null)
m_ProfileDataSource = ProfileDataSourceSettings.GetSettings();
return m_ProfileDataSource;
}
}

static GUIStyle dropdownTitleStyle;
static GUIStyle menuOptionStyle;
static GUIStyle horizontalBarStyle;
Expand Down Expand Up @@ -179,10 +188,12 @@ public override void OnGUI(Rect window)
if (CloudProjectSettings.projectId != String.Empty)
{
EditorGUI.LabelField(refreshButtonRect, EditorGUIUtility.IconContent(refreshIcon));
if (evt.type == EventType.MouseDown && refreshButtonRect.Contains(evt.mousePosition))
if (evt.type == EventType.MouseDown && refreshButtonRect.Contains(evt.mousePosition) && !m_isRefreshingCCDDataSources)
{
m_isRefreshingCCDDataSources = true;
await ProfileDataSourceSettings.UpdateCCDDataSourcesAsync(CloudProjectSettings.projectId, true);
SyncProfileGroupTypes();
m_isRefreshingCCDDataSources = false;
return;
}
}
Expand Down Expand Up @@ -246,8 +257,12 @@ public override void OnGUI(Rect window)
m_WindowRect.height = 120;
}
EditorGUI.LabelField(refreshButtonRect, EditorGUIUtility.IconContent(refreshIcon));
if (evt.type == EventType.MouseDown && refreshButtonRect.Contains(evt.mousePosition))
if (evt.type == EventType.MouseDown && refreshButtonRect.Contains(evt.mousePosition) && !m_isRefreshingCCDDataSources)
{
m_isRefreshingCCDDataSources = true;
await ProfileDataSourceSettings.UpdateCCDDataSourcesAsync(CloudProjectSettings.projectId, true);
SyncProfileGroupTypes();
m_isRefreshingCCDDataSources = false;
return;
}
EditorGUILayout.LabelField(String.Format("{0} Badges", m_Bucket.GetVariableBySuffix($"{nameof(CcdBucket)}{nameof(CcdBucket.Name)}").Value), dropdownTitleStyle);
Expand Down Expand Up @@ -417,7 +432,7 @@ internal EditorHostedOption()
OptionName = "Editor Hosted";
state = DropdownState.EditorHosted;
BuildPath = AddressableAssetSettings.kRemoteBuildPathValue;
LoadPath = AddressableAssetSettings.kRemoteLoadPathValue;
LoadPath = AddressableAssetSettings.RemoteLoadPathValue;
}

internal override void Draw(Action action)
Expand Down
9 changes: 8 additions & 1 deletion Editor/GUI/ProfileWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,21 @@ internal class ProfileWindow : EditorWindow

float m_HorizontalSplitterRatio = k_DefaultHorizontalSplitterRatio;

private ProfileDataSourceSettings m_ProfileDataSource;

internal AddressableAssetSettings settings
{
get { return AddressableAssetSettingsDefaultObject.Settings; }
}

internal ProfileDataSourceSettings dataSourceSettings
{
get { return ProfileDataSourceSettings.GetSettings(); }
get
{
if (m_ProfileDataSource == null)
m_ProfileDataSource = ProfileDataSourceSettings.GetSettings();
return m_ProfileDataSource;
}
}

private ProfileTreeView m_ProfileTreeView;
Expand Down
62 changes: 54 additions & 8 deletions Editor/HostingServices/HostingServicesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using UnityEditor.AddressableAssets.Build.DataBuilders;
using UnityEditor.AddressableAssets.Settings;
using UnityEngine;
using UnityEngine.Serialization;
Expand Down Expand Up @@ -51,6 +52,24 @@ internal class HostingServiceInfo
ILogger m_Logger;
List<Type> m_RegisteredServiceTypes;

internal bool exitingEditMode = false;

[Serializable]
internal class ProfileVariablesInfo
{
[SerializeField]
internal string key;
[SerializeField]
internal string value;
}
[SerializeField]
List<ProfileVariablesInfo> m_GlobalProfileVariablesInfos;

/// <summary>
/// Key/Value pairs valid for profile variable substitution
/// </summary>
public Dictionary<string, string> GlobalProfileVariables { get; private set; }

/// <summary>
/// Direct logging output of all managed services
/// </summary>
Expand Down Expand Up @@ -96,11 +115,6 @@ public static void BatchMode()
BatchMode(AddressableAssetSettingsDefaultObject.Settings);
}

/// <summary>
/// Key/Value pairs valid for profile variable substitution
/// </summary>
public Dictionary<string, string> GlobalProfileVariables { get; private set; }

/// <summary>
/// Indicates whether or not this HostingServiceManager is initialized
/// </summary>
Expand Down Expand Up @@ -146,6 +160,7 @@ public int NextInstanceId
/// </summary>
public HostingServicesManager()
{
m_GlobalProfileVariablesInfos = new List<ProfileVariablesInfo>();
GlobalProfileVariables = new Dictionary<string, string>();
m_HostingServiceInfos = new List<HostingServiceInfo>();
m_HostingServiceInfoMap = new Dictionary<IHostingService, HostingServiceInfo>();
Expand Down Expand Up @@ -234,7 +249,8 @@ 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, true);
m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.HostingServicesManagerModified, this, true, true);
AddressableAssetUtility.OpenAssetIfUsingVCIntegration(m_Settings);

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

/// <summary>
Expand All @@ -266,14 +283,26 @@ public void OnEnable()
m_Settings.OnModification -= OnSettingsModification;
m_Settings.OnModification += OnSettingsModification;
m_Settings.profileSettings.RegisterProfileStringEvaluationFunc(EvaluateGlobalProfileVariableKey);

bool hasAnEnabledService = false;
foreach (var svc in HostingServices)
{
svc.Logger = m_Logger;
m_Settings.profileSettings.RegisterProfileStringEvaluationFunc(svc.EvaluateProfileString);
(svc as BaseHostingService)?.OnEnable();
var baseSvc = svc as BaseHostingService;
baseSvc?.OnEnable();

if (!hasAnEnabledService)
hasAnEnabledService = svc.IsHostingServiceRunning || baseSvc != null && baseSvc.WasEnabled;
}

RefreshGlobalProfileVariables();
if (!exitingEditMode || exitingEditMode && hasAnEnabledService && IsUsingPackedPlayMode())
RefreshGlobalProfileVariables();
}

bool IsUsingPackedPlayMode()
{
return m_Settings.ActivePlayModeDataBuilder != null && m_Settings.ActivePlayModeDataBuilder.GetType() == typeof(BuildScriptPackedPlayMode);
}

/// <summary>
Expand Down Expand Up @@ -315,6 +344,15 @@ public void OnBeforeSerialize()
m_RegisteredServiceTypeRefs.Clear();
foreach (var type in m_RegisteredServiceTypes)
m_RegisteredServiceTypeRefs.Add(TypeToClassRef(type));

m_GlobalProfileVariablesInfos.Clear();
foreach (var profileVar in GlobalProfileVariables)
{
var info = new ProfileVariablesInfo();
info.key = profileVar.Key;
info.value = profileVar.Value;
m_GlobalProfileVariablesInfos.Add(info);
}
}

/// <summary> Ensure object is ready for serialization, and calls <see cref="IHostingService.OnBeforeSerialize"/> methods
Expand All @@ -339,6 +377,12 @@ public void OnAfterDeserialize()
if (type == null) continue;
m_RegisteredServiceTypes.Add(type);
}

GlobalProfileVariables = new Dictionary<string, string>();
foreach (var profileVar in m_GlobalProfileVariablesInfos)
{
GlobalProfileVariables.Add(profileVar.key, profileVar.value);
}
}

/// <summary>
Expand All @@ -365,6 +409,8 @@ public void RefreshGlobalProfileVariables()
vars.Add(KPrivateIpAddressKey + "_" + i, ipAddressList[i].ToString());
}
}
m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.HostingServicesManagerModified, this, true, true);
AddressableAssetUtility.OpenAssetIfUsingVCIntegration(m_Settings);
}

// Internal for unit tests
Expand Down
2 changes: 2 additions & 0 deletions Editor/Settings/AddressableAssetGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ internal void Validate()
}
if (m_SchemaSet.Schemas[i].Group == null)
m_SchemaSet.Schemas[i].Group = this;

m_SchemaSet.Schemas[i].Validate();
}
}

Expand Down
8 changes: 8 additions & 0 deletions Editor/Settings/AddressableAssetGroupSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ internal set
{
m_Group = value;
if (m_Group != null)
{
OnSetGroup(m_Group);
Validate();
}
}
}

Expand All @@ -37,6 +40,11 @@ protected virtual void OnSetGroup(AddressableAssetGroup group)
{
}

internal virtual void Validate()
{

}

/// <summary>
/// Used to display the GUI of the schema.
/// </summary>
Expand Down
15 changes: 14 additions & 1 deletion Editor/Settings/AddressableAssetProfileSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ internal string CreateDefaultProfile()
CreateValue(AddressableAssetSettings.kLocalBuildPath, AddressableAssetSettings.kLocalBuildPathValue);
CreateValue(AddressableAssetSettings.kLocalLoadPath, AddressableAssetSettings.kLocalLoadPathValue);
CreateValue(AddressableAssetSettings.kRemoteBuildPath, AddressableAssetSettings.kRemoteBuildPathValue);
CreateValue(AddressableAssetSettings.kRemoteLoadPath, AddressableAssetSettings.kRemoteLoadPathValue);
CreateValue(AddressableAssetSettings.kRemoteLoadPath, AddressableAssetSettings.RemoteLoadPathValue);
}
return GetDefaultProfileId();
}
Expand Down Expand Up @@ -658,6 +658,7 @@ internal string CreateValue(string variableName, string defaultValue, bool inlin
pro.values.Add(new BuildProfile.ProfileEntry(id, defaultValue));
}
}
SetDirty(AddressableAssetSettings.ModificationEvent.ProfileModified, null, true);
return id;
}

Expand Down Expand Up @@ -713,5 +714,17 @@ internal static string GenerateUniqueName(string baseName, IEnumerable<string> e
}
return newName;
}

internal void CreateDuplicateVariableWithNewName(AddressableAssetSettings addressableAssetSettings, string newVariableName, string variableNameToCopyFrom)
{
var activeProfileId = addressableAssetSettings.activeProfileId;
string newVarId = CreateValue(newVariableName, GetValueByName(activeProfileId, variableNameToCopyFrom));
string oldVarId = GetVariableId(variableNameToCopyFrom);
foreach (var profile in profiles)
{
profile.SetValueById(newVarId, profile.GetValueById(oldVarId));
SetDirty(AddressableAssetSettings.ModificationEvent.ProfileModified, profile, true);
}
}
}
}
Loading

0 comments on commit 966984d

Please sign in to comment.