docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GroupResolver

    Provides support for placing assets into different UnityEditor.AddressableAssets.Settings.AddressableAssetGroups.

    Inheritance
    object
    GroupResolver
    Namespace: UnityEditor.Localization.Addressables
    Assembly: Unity.Localization.Editor.dll
    Syntax
    [Serializable]
    public class GroupResolver
    Examples

    This example places all English assets into a local group and all other languages into a remote group which could then be downloaded after the game is released.

    using System.Collections.Generic;
    using UnityEditor;
    using UnityEditor.AddressableAssets.Settings;
    using UnityEditor.Localization.Addressables;
    using UnityEngine;
    using UnityEngine.Localization;
    
    /// <summary>
    /// Places all English assets into a local group and all other languages into a remote group which could be downloaded after the game is released.
    /// </summary>
    [System.Serializable]
    public class GroupResolverExample : GroupResolver
    {
        public string localAssetsGroup = "Localization-Local";
        public string remoteAssetsGroup = "Localization-Remote";
    
        [MenuItem("Localization Samples/Create Group Resolver")]
        static void CreateAsset()
        {
            var path = EditorUtility.SaveFilePanelInProject("Create Addressable Rules", "Localization Addressable Group Rules.asset", "asset", "");
            if (string.IsNullOrEmpty(path))
                return;
    
            var instance = ScriptableObject.CreateInstance<AddressableGroupRules>();
            var resolver = new GroupResolverExample();
    
            // Apply our custom group resolver to everything
            instance.LocaleResolver = resolver;
            instance.AssetTablesResolver = resolver;
            instance.AssetResolver = resolver;
            instance.StringTablesResolver = resolver;
    
            // Make this our new AddressableGroupRules
            AssetDatabase.CreateAsset(instance, path);
            AddressableGroupRules.Instance = instance;
        }
    
        public override string GetExpectedGroupName(IList<LocaleIdentifier> locales, Object asset, AddressableAssetSettings aaSettings)
        {
            // Use default behaviour for shared assets
            if (locales == null || locales.Count == 0)
                return base.GetExpectedGroupName(locales, asset, aaSettings);
    
            var locale = locales[0];
            if (locale.Code == "en")
                return localAssetsGroup;
            return remoteAssetsGroup;
        }
    }

    Constructors

    Name Description
    GroupResolver()

    Creates a new default instance of GroupResolver.

    GroupResolver(string)

    Creates a new instance which will store all assets into a single group.

    GroupResolver(string, string)

    Creates an instance using custom group names for each Locale.

    GroupResolver(AddressableAssetGroup)

    Creates a new instance which will store all assets into a single group;

    Properties

    Name Description
    LocaleGroupNamePattern

    The name to use when generating a new UnityEditor.AddressableAssets.Settings.AddressableAssetGroup for a Locale.

    MarkEntriesReadOnly

    Should new Entries be marked as read only? This will prevent editing them in the Addressables window.

    SharedGroup

    The group to use for shared assets. If null then a new group will be created using SharedGroupName.

    SharedGroupName

    The name to use when creating a new group.

    Methods

    Name Description
    AddLocaleGroup(LocaleIdentifier, AddressableAssetGroup)

    Add a group for the LocaleIdentifier. If a Group is already assigned it will be replaced with the new group.

    AddToGroup(Object, IList<LocaleIdentifier>, AddressableAssetSettings, bool)

    Add an asset to an UnityEditor.AddressableAssets.Settings.AddressableAssetGroup. The asset will be moved into a group which either matches SharedGroup or SharedGroupName.

    GetExpectedGroupName(IList<LocaleIdentifier>, Object, AddressableAssetSettings)

    Returns the name of the group that the asset will be moved to when calling AddToGroup(Object, IList<LocaleIdentifier>, AddressableAssetSettings, bool).

    GetExpectedSharedGroupName(IList<LocaleIdentifier>, Object, AddressableAssetSettings)

    Returns the name that the Shared group is expected to have.

    GetGroup(IList<LocaleIdentifier>, Object, AddressableAssetSettings, bool)

    Returns the Addressable group for the asset.

    GetLocaleGroup(LocaleIdentifier)

    Returns the active group assigned to the LocaleIdentifier or null if one has not been assigned.

    RemoveLocaleGroup(LocaleIdentifier)

    Removes the group for the chosen Locale Id.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)