docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Property this

    this[string]

    Gets or sets the IVariable with the specified name.

    Declaration
    public IVariable this[string name] { get; set; }
    Parameters
    Type Name Description
    string name

    The name of the variable.

    Property Value
    Type Description
    IVariable

    The found variable.

    Examples

    This example shows how to get and add a local variable.

    var localizedString = new LocalizedString("My Table", "My Entry");
    
    // An example of a Smart String using the variable would be: "You have {player-money:C}.".
    // :C will apply the current Locale currency and number formatting.
    localizedString.Add("player-money", new FloatVariable { Value = 100.45f });
    
    // Get a variable from the localized string
    var variable = localizedString["player-money"] as FloatVariable;
    Debug.Log("The value is " + variable);
    Exceptions
    Type Condition
    KeyNotFoundException

    Thrown if a variable with the specified name does not exist.

    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)