Class KeyDatabase | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class KeyDatabase

    The key database is responsible for holding localization keys and associating keys to unique ids.

    Inheritance
    System.Object
    KeyDatabase
    Namespace: UnityEngine.Localization
    Syntax
    public class KeyDatabase : ScriptableObject, ISerializationCallbackReceiver

    Fields

    EmptyId

    Declaration
    public const uint EmptyId = 0U
    Field Value
    Type Description
    System.UInt32

    Properties

    Entries

    All Key Database entries.

    Declaration
    public List<KeyDatabase.KeyDatabaseEntry> Entries { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.List<KeyDatabase.KeyDatabaseEntry>

    Methods

    AddKey(String)

    Adds a new key to the database if one does not already exists with the same value. Duplicates are not allowed.

    Declaration
    public KeyDatabase.KeyDatabaseEntry AddKey(string key)
    Parameters
    Type Name Description
    System.String key
    Returns
    Type Description
    KeyDatabase.KeyDatabaseEntry

    The new key or null if the key already exists.

    Contains(String)

    Is the key value used by any entries in the database?

    Declaration
    public bool Contains(string key)
    Parameters
    Type Name Description
    System.String key

    Key to check.

    Returns
    Type Description
    System.Boolean

    Contains(UInt32)

    Is the Id value used by any entries in the database?

    Declaration
    public bool Contains(uint id)
    Parameters
    Type Name Description
    System.UInt32 id

    Id to check.

    Returns
    Type Description
    System.Boolean

    FindSimilarKey(String, out Int32)

    Returns the KeyDatabaseEntry that is the most similar to the text. Uses the Levenshtein distance method.

    Declaration
    public KeyDatabase.KeyDatabaseEntry FindSimilarKey(string text, out int distance)
    Parameters
    Type Name Description
    System.String text

    The text to match against.

    System.Int32 distance

    The number of edits needed to turn text into the returned KeyDatabaseEntry, 0 being an exact match.

    Returns
    Type Description
    KeyDatabase.KeyDatabaseEntry

    The KeyDatabaseEntry that is the most similar to the text or null if one could not be found.

    GenerateUniqueId()

    Declaration
    protected virtual uint GenerateUniqueId()
    Returns
    Type Description
    System.UInt32

    GetId(String)

    Get the unique Id for the key from the database.

    Declaration
    public uint GetId(string key)
    Parameters
    Type Name Description
    System.String key

    The key whose id is being requested.

    Returns
    Type Description
    System.UInt32

    The keys id value or EmptyId if one does not exist.

    GetId(String, Boolean)

    Declaration
    public uint GetId(string key, bool addNewKey)
    Parameters
    Type Name Description
    System.String key
    System.Boolean addNewKey
    Returns
    Type Description
    System.UInt32

    GetKey(UInt32)

    Get the key associated with the id.

    Declaration
    public string GetKey(uint id)
    Parameters
    Type Name Description
    System.UInt32 id

    Id the key belongs to.

    Returns
    Type Description
    System.String

    The found key or null if one can not be found.

    OnAfterDeserialize()

    Declaration
    public void OnAfterDeserialize()

    OnBeforeSerialize()

    Declaration
    public void OnBeforeSerialize()

    RemoveKey(String)

    Attempts to remove the key from the database.

    Declaration
    public void RemoveKey(string key)
    Parameters
    Type Name Description
    System.String key

    The key to be removed.

    RemoveKey(UInt32)

    Attempts to remove the key with provided id.

    Declaration
    public void RemoveKey(uint id)
    Parameters
    Type Name Description
    System.UInt32 id

    RenameKey(String, String)

    Rename the key value if it exists.

    Declaration
    public void RenameKey(string oldValue, string newValue)
    Parameters
    Type Name Description
    System.String oldValue
    System.String newValue

    RenameKey(UInt32, String)

    Rename the key value for the provided id if it exists.

    Declaration
    public void RenameKey(uint id, string newValue)
    Parameters
    Type Name Description
    System.UInt32 id
    System.String newValue
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023