Class AddressableAssetSettings
Contains editor data for the addressables system.
Inheritance
Namespace: UnityEditor.AddressableAssets
Syntax
public class AddressableAssetSettings : ScriptableObject
Fields
kLocalBuildPath
Default name of local build path.
Declaration
public const string kLocalBuildPath = "LocalBuildPath"
Field Value
| Type | Description |
|---|---|
| System.String |
kLocalLoadPath
Default name of local load path.
Declaration
public const string kLocalLoadPath = "LocalLoadPath"
Field Value
| Type | Description |
|---|---|
| System.String |
kNewGroupName
Default name of a newly created group.
Declaration
public const string kNewGroupName = "New Group"
Field Value
| Type | Description |
|---|---|
| System.String |
kRemoteBuildPath
Default name of remote build path.
Declaration
public const string kRemoteBuildPath = "RemoteBuildPath"
Field Value
| Type | Description |
|---|---|
| System.String |
kRemoteLoadPath
Default name of remote load path.
Declaration
public const string kRemoteLoadPath = "RemoteLoadPath"
Field Value
| Type | Description |
|---|---|
| System.String |
Properties
ActivePlayerDataBuilder
Get the active data builder for player data.
Declaration
public IDataBuilder ActivePlayerDataBuilder { get; }
Property Value
| Type | Description |
|---|---|
| IDataBuilder |
ActivePlayerDataBuilderIndex
Get the index of the active player data builder.
Declaration
public int ActivePlayerDataBuilderIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
ActivePlayModeDataBuilder
Get the active data builder for editor play mode data.
Declaration
public IDataBuilder ActivePlayModeDataBuilder { get; }
Property Value
| Type | Description |
|---|---|
| IDataBuilder |
ActivePlayModeDataBuilderIndex
Get the index of the active play mode data builder.
Declaration
public int ActivePlayModeDataBuilderIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
activeProfileId
The active profile id.
Declaration
public string activeProfileId { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
AssetPath
The path of the settings asset.
Declaration
public string AssetPath { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
buildSettings
Build settings object.
Declaration
public AddressableAssetBuildSettings buildSettings { get; }
Property Value
| Type | Description |
|---|---|
| AddressableAssetBuildSettings |
ConfigFolder
The folder of the settings asset.
Declaration
public string ConfigFolder { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
currentHash
Hash of the current settings. This value is recomputed if anything changes.
Declaration
public Hash128 currentHash { get; }
Property Value
| Type | Description |
|---|---|
| Hash128 |
DataBuilderFolder
The folder for the script assets.
Declaration
public string DataBuilderFolder { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
DataBuilders
List of ScriptableObjects that implement the IDataBuilder interface. These are used to create data for editor play mode and for player builds.
Declaration
public List<ScriptableObject> DataBuilders { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<ScriptableObject> |
DefaultGroup
The default group. This group is used when marking assets as addressable via the inspector.
Declaration
public AddressableAssetGroup DefaultGroup { get; set; }
Property Value
| Type | Description |
|---|---|
| AddressableAssetGroup |
GroupFolder
The folder for the group assets.
Declaration
public string GroupFolder { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
groups
List of asset groups.
Declaration
public List<AddressableAssetGroup> groups { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<AddressableAssetGroup> |
GroupSchemaFolder
The folder for the asset group schema assets.
Declaration
public string GroupSchemaFolder { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
HostingServicesManager
Get the HostingServicesManager object.
Declaration
public HostingServicesManager HostingServicesManager { get; }
Property Value
| Type | Description |
|---|---|
| HostingServicesManager |
InitializationObjects
List of ScriptableObjects that implement the IObjectInitializationDataProvider interface for providing runtime initialization.
Declaration
public List<ScriptableObject> InitializationObjects { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<ScriptableObject> |
IsPersisted
Returns whether this settings object is persisted to an asset.
Declaration
public bool IsPersisted { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
OnDataBuilderComplete
Event for handling the result of a DataBuilder.Build call.
Declaration
public Action<AddressableAssetSettings, IDataBuilder, IDataBuilderResult> OnDataBuilderComplete { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Action<AddressableAssetSettings, IDataBuilder, IDataBuilderResult> |
OnModification
Event for handling settings changes. The object passed depends on the event type.
Declaration
public Action<AddressableAssetSettings, AddressableAssetSettings.ModificationEvent, object> OnModification { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Action<AddressableAssetSettings, AddressableAssetSettings.ModificationEvent, System.Object> |
PlayerBuildVersion
The version of the player build. This is implemented as a timestamp int UTC of the form string.Format("{0:D4}.{1:D2}.{2:D2}.{3:D2}.{4:D2}.{5:D2}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second).
Declaration
public string PlayerBuildVersion { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
profileSettings
Profile settings object.
Declaration
public AddressableAssetProfileSettings profileSettings { get; }
Property Value
| Type | Description |
|---|---|
| AddressableAssetProfileSettings |
SchemaTemplates
Get defined schema templates.
Declaration
public List<AddressableAssetGroupSchemaTemplate> SchemaTemplates { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<AddressableAssetGroupSchemaTemplate> |
Methods
AddDataBuilder(IDataBuilder, Boolean)
Adds a data builder.
Declaration
public bool AddDataBuilder(IDataBuilder builder, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataBuilder | builder | The data builder to add. |
| System.Boolean | postEvent | Indicates if an even should be posted to the Addressables event system for this change. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the data builder was added. |
AddInitializationObject(IObjectInitializationDataProvider, Boolean)
Adds an initialization object.
Declaration
public bool AddInitializationObject(IObjectInitializationDataProvider initObject, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| IObjectInitializationDataProvider | initObject | The initialization object to add. |
| System.Boolean | postEvent | Indicates if an even should be posted to the Addressables event system for this change. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the initialization object was added. |
AddLabel(String, Boolean)
Add a new label.
Declaration
public void AddLabel(string label, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | label | The label name. |
| System.Boolean | postEvent | Send modification event. |
AddSchemaTemplate(String, String, Type[])
Adds a named set of schema types for use in the editor GUI.
Declaration
public bool AddSchemaTemplate(string displayName, string description, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | displayName | The display name of the template. |
| System.String | description | Tooltip text for the template. |
| System.Type[] | types | The schema types for the template. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the template was added, false otherwise. |
BuildPlayerContent()
Runs the active player data build script to create runtime data.
Declaration
public static void BuildPlayerContent()
CleanPlayerContent()
Deletes all created runtime data for the active player data builder.
Declaration
public static void CleanPlayerContent()
Create(String, String, Boolean, Boolean)
Create a new AddressableAssetSettings object.
Declaration
public static AddressableAssetSettings Create(string configFolder, string configName, bool createDefaultGroups, bool isPersisted)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | configFolder | The folder to store the settings object. |
| System.String | configName | The name of the settings object. |
| System.Boolean | createDefaultGroups | If true, create groups for player data and local packed content. |
| System.Boolean | isPersisted | If true, assets are created. |
Returns
| Type | Description |
|---|---|
| AddressableAssetSettings |
CreateAssetReference(String)
Create an AssetReference object. If the asset is not already addressable, it will be added.
Declaration
public AssetReference CreateAssetReference(string guid)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | guid | The guid of the asset reference. |
Returns
| Type | Description |
|---|---|
| AssetReference | Returns the newly created AssetReference. |
CreateGroup(String, Boolean, Boolean, Boolean, List<AddressableAssetGroupSchema>, Type[])
Create a new asset group.
Declaration
public AddressableAssetGroup CreateGroup(string groupName, bool setAsDefaultGroup, bool readOnly, bool postEvent, List<AddressableAssetGroupSchema> schemasToCopy, params Type[] types)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | groupName | The group name. |
| System.Boolean | setAsDefaultGroup | Set the new group as the default group. |
| System.Boolean | readOnly | Is the new group read only. |
| System.Boolean | postEvent | Post modification event. |
| System.Collections.Generic.List<AddressableAssetGroupSchema> | schemasToCopy | Schema set to copy from. |
| System.Type[] | types | Types of schemas to add. |
Returns
| Type | Description |
|---|---|
| AddressableAssetGroup | The newly created group. |
CreateOrMoveEntry(String, AddressableAssetGroup, Boolean, Boolean)
Create a new entry, or if one exists in a different group, move it into the new group.
Declaration
public AddressableAssetEntry CreateOrMoveEntry(string guid, AddressableAssetGroup targetParent, bool readOnly = false, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | guid | The asset guid. |
| AddressableAssetGroup | targetParent | The group to add the entry to. |
| System.Boolean | readOnly | Is the new entry read only. |
| System.Boolean | postEvent | Send modification event. |
Returns
| Type | Description |
|---|---|
| AddressableAssetEntry |
FindAssetEntry(String)
Find and asset entry by guid.
Declaration
public AddressableAssetEntry FindAssetEntry(string guid)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | guid | The asset guid. |
Returns
| Type | Description |
|---|---|
| AddressableAssetEntry | The found entry or null. |
FindGroup(Func<AddressableAssetGroup, Boolean>)
Find asset group by functor.
Declaration
public AddressableAssetGroup FindGroup(Func<AddressableAssetGroup, bool> func)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<AddressableAssetGroup, System.Boolean> | func | The functor to call on each group. The first group that evaluates to true is returned. |
Returns
| Type | Description |
|---|---|
| AddressableAssetGroup | The group found or null. |
FindGroup(String)
Find asset group by name.
Declaration
public AddressableAssetGroup FindGroup(string groupName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | groupName | The name of the group. |
Returns
| Type | Description |
|---|---|
| AddressableAssetGroup | The group found or null. |
GetAllAssets(List<AddressableAssetEntry>, Func<AddressableAssetGroup, Boolean>)
Gets all asset entries from all groups.
Declaration
public void GetAllAssets(List<AddressableAssetEntry> assets, Func<AddressableAssetGroup, bool> filter = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.List<AddressableAssetEntry> | assets | The list of asset entries. |
| System.Func<AddressableAssetGroup, System.Boolean> | filter | A method to filter groups. Groups will be processed if filter is null, or it returns TRUE |
GetDataBuilder(Int32)
Get The data builder at a specifc index.
Declaration
public IDataBuilder GetDataBuilder(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the builder. |
Returns
| Type | Description |
|---|---|
| IDataBuilder | The data builder at the specified index. |
GetDefault(Boolean, Boolean)
[Obsolete] Get the default addressables settings object
Declaration
[Obsolete("Use AddressableAssetSettingsDefaultObject.Settings instead. (UnityUpgradable) -> AddressableAssetSettingsDefaultObject.Settings")]
public static AddressableAssetSettings GetDefault(bool create, bool browse)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | create | Create settings asset if it does not exist. |
| System.Boolean | browse | Unused. |
Returns
| Type | Description |
|---|---|
| AddressableAssetSettings | The default settings object or null if it has not been set. |
GetInitializationObject(Int32)
Get the IObjectInitializationDataProvider at a specifc index.
Declaration
public IObjectInitializationDataProvider GetInitializationObject(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index of the initialization object. |
Returns
| Type | Description |
|---|---|
| IObjectInitializationDataProvider | The initialization object at the specified index. |
RemoveAssetEntry(String, Boolean)
Remove an asset entry.
Declaration
public bool RemoveAssetEntry(string guid, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | guid | The guid of the asset. |
| System.Boolean | postEvent | Send modifcation event. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the entry was found and removed. |
RemoveDataBuilder(Int32, Boolean)
Remove the data builder at the sprcified index.
Declaration
public bool RemoveDataBuilder(int index, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index to remove. |
| System.Boolean | postEvent | Indicates if an even should be posted to the Addressables event system for this change. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the builder was removed. |
RemoveGroup(AddressableAssetGroup)
Remove an asset group.
Declaration
public void RemoveGroup(AddressableAssetGroup g)
Parameters
| Type | Name | Description |
|---|---|---|
| AddressableAssetGroup | g |
RemoveInitializationObject(Int32, Boolean)
Remove the initialization object at the specified index.
Declaration
public bool RemoveInitializationObject(int index, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index to remove. |
| System.Boolean | postEvent | Indicates if an even should be posted to the Addressables event system for this change. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the initialization object was removed. |
RemoveLabel(String, Boolean)
Remove a label by name.
Declaration
public void RemoveLabel(string label, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | label | The label name. |
| System.Boolean | postEvent | Send modification event. |
RemoveSchemaTemplate(Int32, Boolean)
Remove the schema at the specified index.
Declaration
public bool RemoveSchemaTemplate(int index, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index to remove at. |
| System.Boolean | postEvent | Indicates if an even should be posted to the Addressables event system for this change. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the schema was removed. |
SetDataBuilderAtIndex(Int32, IDataBuilder, Boolean)
Sets the data builder at the specified index.
Declaration
public bool SetDataBuilderAtIndex(int index, IDataBuilder builder, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index to set the builder. |
| IDataBuilder | builder | The builder to set. This must be a valid scriptable object that implements the IDataBuilder interface. |
| System.Boolean | postEvent | Indicates if an even should be posted to the Addressables event system for this change. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the builder was set, false otherwise. |
SetDirty(AddressableAssetSettings.ModificationEvent, Object, Boolean)
Marks the object as modified.
Declaration
public void SetDirty(AddressableAssetSettings.ModificationEvent modificationEvent, object eventData, bool postEvent)
Parameters
| Type | Name | Description |
|---|---|---|
| AddressableAssetSettings.ModificationEvent | modificationEvent | The event type that is changed. |
| System.Object | eventData | The object data that corresponds to the event. |
| System.Boolean | postEvent | If true, the event is propagated to callbacks. |
SetInitializationObjectAtIndex(Int32, IObjectInitializationDataProvider, Boolean)
Sets the initialization object at the specified index.
Declaration
public bool SetInitializationObjectAtIndex(int index, IObjectInitializationDataProvider initObject, bool postEvent = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | The index to set the initialization object. |
| IObjectInitializationDataProvider | initObject | The initialization object to set. This must be a valid scriptable object that implements the IInitializationObject interface. |
| System.Boolean | postEvent | Indicates if an even should be posted to the Addressables event system for this change. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the initialization object was set, false otherwise. |