docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method TryGetValue

    TryGetValue(string, out IVariable)

    Gets the IVariable with the specified name.

    Declaration
    public bool TryGetValue(string name, out IVariable value)
    Parameters
    Type Name Description
    string name

    The name of the variable.

    IVariable value

    The variable that was found or default.

    Returns
    Type Description
    bool

    true if a variable was found and false if one could not.

    Implements
    IVariableGroup.TryGetValue(string, out IVariable)
    Examples

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

    FloatVariable playerScore = null;
    if (!localizedString.TryGetValue("player-score", out var variable))
    {
        playerScore = new FloatVariable();
        localizedString.Add("player-score", playerScore);
    }
    else
    {
        playerScore = variable as FloatVariable;
    }
    
    playerScore.Value += 10;
    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)