docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Property InitializationOperation

    InitializationOperation

    The localization system may not be immediately ready. Loading Locales, preloading assets etc. This operation can be used to check when the system is ready. You can yield on this in a coroutine to wait. If InitializeSynchronously is true then this operation will complete synchronously the first time it is called. Uses WaitForCompletion to force the loading to complete synchronously. Please note that WaitForCompletion is not supported on WebGL and InitializeSynchronously will be ignored when running on WebGL.

    Declaration
    public static AsyncOperationHandle<LocalizationSettings> InitializationOperation { get; }
    Property Value
    Type Description
    AsyncOperationHandle<LocalizationSettings>
    Examples

    This shows how to use a coroutine to wait for the Initialization Operation to complete.

    public class InitializationOperationExampleAsync : MonoBehaviour
    {
        IEnumerator Start()
        {
            yield return LocalizationSettings.InitializationOperation;
    
            Debug.Log("Initialization Completed");
        }
    }

    This shows how to use the UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle<TObject>.Completed event to get a callback when the Initialization Operation is complete.

    public class InitializationOperationExampleAsyncEvent : MonoBehaviour
    {
        void Start()
        {
            var init = LocalizationSettings.InitializationOperation;
            init.Completed += a => Debug.Log("Initialization Completed");
        }
    }

    This shows how to force the Initialization Operation to complete synchronously using WaitForCompletion. Note WaitForCompletion is not supported on WebGL.

    public class InitializationOperationExampleSync : MonoBehaviour
    {
        void Start()
        {
            // Force initialization to complete synchronously.
            LocalizationSettings.InitializationOperation.WaitForCompletion();
        }
    }
    In This Article
    Back to top
    Copyright © 2024 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)