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 a variable group named "globals".

    var source = LocalizationSettings.StringDatabase.SmartFormatter.GetSourceExtension<PersistentVariablesSource>();
    
    var globalVariables = source["globals"];
    
    var intVariable = new IntVariable { Value = 123 };
    
    // This can be accessed from a Smart String with the following syntax: {globals.my-int}
    globalVariables.Add("my-int", intVariable);
    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)