docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Reflection source

    The Reflection source is used to select using .Net Reflection. Named placeholders are evaluated against the current object. The Reflection Source can be used to extract an object from a property, field or method.

    Note

    When using a method, the method must be parameterless and not return void.

    Example Smart String Arguments Result
    The value is {gameObject.name} [!code-cs] The value is Camera
    You can call methods to modify values such as {0.ToUpper} [!code-cs] You can call methods to modify values such as HELLO WORLD
    My name is {Name} and I am {Age} years old. [!code-cs] [!code-cs] My name is Juan Pérez and I am 39 years old.
    Mr {name.ToCharArray.0} {surname} [!code-cs] Mr Y Taro

    The following example shows how the Person instance could be provided as an argument.

    var myLocalizedString = new LocalizedString("My Table", "My Entry");
    
    var person = new Person { Name = "Michael Scott", Age = 40 };
    myLocalizedString.Arguments = new object[] { person };
    
    Debug.Log(myLocalizedString.GetLocalizedString());
    
    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)