Locale Selector broken with domain reloading turned off

Just upgraded to the newest version of Localization Tools (Version 1.0.0-pre.9 - May 12, 2021) and when I recompile scripts (or open the project) and press play - it works perfectly fine.
But when I exit play mode and re-enter, I get hundreds of errors all saying “OperationException : SelectedLocale is null” as well as:

No Locale could be selected:
The following (2) Locales were considered:
    English (en)
    German (de)
The following (1) IStartupLocaleSelectors were used:
    UnityEngine.Localization.Settings.SpecificLocaleSelector

I tried to fix it in my own script but wasn’t able to - I will load the previous release because all systems using any localizationStrings stop working (so I can’t playtest)

Yes, it is working on Version 1.0.0-pre.8 - May 12, 2021.
Unfortunately there is a major code change between those versions, so I had to change it twice in all scripts that use the localizedString.
(But at the second time, I declared a define “NEW_LOCALIZATION” which I can manually set to switch between those versions.)

Hi,
Could you file a bug report so we can look into this?

Probably same as mine

and this one:

(Note: still worth investigating your problems and even submitting bug report, I’m just providing more information which may or may not helpful)

1 Like

Just taken a look and its actually a bug in the Addressables Asset Database play mode script. I have spoken to the team and they are already aware of the issue and have a fix in the next release due this week. So you should be able to update the Addressables package in the package manager once its available to fix the issue.

For now it can be worked around by either changing the Addressables Play mode to Simulate or Use Existing Build

or by changing the method AddOrGetInstanceFromCache in the Addressables package file Runtime\ResourceManager\ResourceProviders\AssetDatabaseProvider.cs to

private static Object AddOrGetInstanceFromCache(Object original)
{
    if (InstanceCache.TryGetValue(original, out AssetInstance inst) && inst.Instance != null)
    {
        inst.LoadCount++;
        return inst.Instance;
    }
    Object o = Object.Instantiate(original);
    o.name = o.name.Substring(0, o.name.Length - 7);
    InstanceCache[original] = new AssetInstance {Instance = o, LoadCount = 1};
    InstanceIDToAsset.Add(o.GetInstanceID(), original);
    return o;
}

If you plan to change the package then you will need to move it out of the PackageCache folder of the change will be reverted. You can move it into your project Packages folder.

2 Likes

Thank you, this is awesome and I didn’t think to try them out before. I can confirm, I switched to Use Existing Build works!

Unfortunately the Simulate throws similar error:

No Locale could be selected:
The following (2) Locales were considered:
    English (en)
    Hungarian (hu)
The following (3) IStartupLocaleSelectors were used:
    UnityEngine.Localization.Settings.SpecificLocaleSelector
    UnityEngine.Localization.Settings.CommandLineLocaleSelector
    UnityEngine.Localization.Settings.SystemLocaleSelector

UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1/<>c__DisplayClass57_0<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>:<add_CompletedTypeless>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>)
DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>) (at Library/PackageCache/com.unity.addressables@1.18.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>:OnWrappedCompleted (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>)
DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>) (at Library/PackageCache/com.unity.addressables@1.18.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>:OnWrappedCompleted (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>)
DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<System.Collections.Generic.IList`1<UnityEngine.Localization.Locale>>) (at Library/PackageCache/com.unity.addressables@1.18.4/Runtime/ResourceManager/Util/DelegateList.cs:69)
UnityEngine.ResourceManagement.ResourceManager:Update (single)
MonoBehaviourCallbackHooks:Update () (at Library/PackageCache/com.unity.addressables@1.18.4/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:26)

Oh I think I had the fix when I tested Simulate so maybe thats why it worked for me :wink:

1 Like

Thanks for the quick response - I think I will wait for the next Version and stay with Version 1.0.0-pre.8 until then.

Strange I didn’t find those posts, usually I only write after searching - but maybe I was lazy this time and just looked over the newest entries on this forum.

But it seems like this has become quite an informative thread. ^^

1 Like

FYI: with the Addressables Version 1.18.9, I think this problem should be fixed. Mine is. (domain reload is off and it’s working)
I also switched back to Asset Database play mode script, so I don’t need to rebuild the entire thing after changing something small in my localization and all.

1 Like