docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method ReleaseTable

    ReleaseTable(TableReference, Locale)

    Releases all references to the table that matches the tableReference and locale. This will also release any references to the SharedTableData providing there are no other references to it, such as different Locale versions of the table that have been loaded. A table is released by calling UnityEngine.AddressableAssets.Addressables.Release(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle) on it which decrements the ref-count. When a given Asset's ref-count is zero, that Asset is ready to be unloaded. For more information, read the Addressables section on when memory is cleared.

    Declaration
    public void ReleaseTable(TableReference tableReference, Locale locale = null)
    Parameters
    Type Name Description
    TableReference tableReference

    A reference to the table. A table reference can be either the name of the table or the table collection name Guid.

    Locale locale

    The Locale version of the table that should be unloaded. When null the SelectedLocale will be used.

    Examples

    This shows how to release a table but prevent it from being unloaded.

    public class ReleaseSample : MonoBehaviour
    {
        AsyncOperationHandle<StringTable> m_Table;
    
        IEnumerator Start()
        {
            TableReference tableReference = "My Game Text";
            m_Table = LocalizationSettings.StringDatabase.GetTableAsync(tableReference);
    
            yield return m_Table;
    
            // To prevent a table from being released we can acquire a reference to it.
            // Now we will always keep this table, even if the Selected Locale is changed.
            Addressables.ResourceManager.Acquire(m_Table);
    
            // We can tell the Localization system to release references to the table.
            LocalizationSettings.StringDatabase.ReleaseTable(tableReference);
        }
    
        private void OnDisable()
        {
            // To release the table we call Release.
            Addressables.Release(m_Table);
        }
    }
    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)