Search code examples
javascriptspark-ar-studio

How to parse number to text


Let's say i have an X value representing the Runtime patch output, it is a number which is the time elapsed since the start of the effect. How can i show that X value into a 2d text?

I tried to use Unpack patch and sending the value to a script and then setting the text what nothing worked for me

I excpect the text to show the Number value while running the effect


Solution

  • According to the documentation you can use ScalarSignal format method:

    const Patches = require('Patches');
    
    const numberFormat = 'Time: {0}';
    const number = Patches.getScalarValue('number');
    
    Patches.setStringValue('value', number.format(numberFormat));
    

    Create proper to & from script values:

    From & to script values

    And link proper nodes in patch editor:

    enter image description here