PreloadingScreen sample project

I have one question about the PreloadingScreen sample project in Localization 1.2.1

In UnityEngine.Localization.Samples.PreloadingScreen.cs we have

void OnEnable()
        {
            LocalizationSettings.SelectedLocaleChanged += SelectedLocaleChanged;

            if (waitForSecondsRealtime == null)
                waitForSecondsRealtime = new WaitForSecondsRealtime(crossFadeTime);

            if (!LocalizationSettings.InitializationOperation.IsDone)
                StartCoroutine(Preload(null));
        }

I wonder why, in the last line, we do a Preload(null). Wouldn’t preloading a null locale results in an invalid operation handle in Preload? Also, isn’t the last line redundant, since in the first line we already tell the game to preload whatever locale the user switch to?

In my own project I preload locales on booting up and the last line gives me errors about invalid operation handle. Deleting the last two lines altogether seems to resolve the issue. However, in the sample project itself, there is no error.

Hope someone familiar with this sample project can explain this a bit.

If you look at the Preload method you will see that if the locale is null then it will attempt to get the locale from LocalizationSettings.SelectedLocaleAsync.Result. Preload does not try to preload the target locale, it just uses it for the label. The purpose of the Preload method is not to actually do preloading but to update the loading screen whilst the initialization and preloading are being performed. What operation are you getting an invalid handle for?

Thanks, now I understood its intention. However, when I copied over that script into my own project, in Preload method, the progressText.text = operation.OperationException.ToString(); line gives me this error:

UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].get_InternalOp () (at Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:212)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].get_OperationException () (at Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:239)
Reimirno.PreloadingScreen+<Preload>d__8.MoveNext () (at Assets/Scripts/PreloadingScreen.cs:66)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <1332c534a8a44623b2e5cc943a0b790e>:0)```

Seems that the operation is not valid for some reason. I did not do any change to the original script except swapping Text with TMP_Text.

In my game, on start up, the game will select a locale based on a saved preference. So essentially on booting up, Preload method will fire twice: one Preload(null) and the other Preload(localeToSwitchTo). The first will always give me that invalid handle error and the second is working as expected.

Can you please file a bug report so we can look into it?