I’m attempting to use the localization package to return numeric data with formatting applied via interpolated strings, but I am having a weirdly hard time getting it to work. Full disclosure: I am a C# noob, so it’s almost certainly user error and likely something very basic.
The goal is to use localized strings for displaying user data of various numeric types so they can be localized for the current locale if necessary (for multidigit values, currency, etc). A simple string interpolation like the following has been failing to obtain the data through the Localization system, no matter what I have tried:
$"{GameManager.GetUserStats().NumericData:N0}"
I tried a few things: setting the string as shown up above in the table, calling it as a local variable (either as a string or referencing the script as a game object type local variable, making sure to only use one or the other), as well as calling the string directly from script just to make sure I was using the correct interpolated values.
The closest I have gotten when using the localization system is having the string display exactly as written if its not flagged as a smart string. Smart string version gives a “Could not evaluate the selector” error.
The selector error tells me that I didn’t set something up correctly somewhere, but trying out the solutions I found that mentioned adding the class as a component and then using that as a local variable just changes where the selector error occurs (on the method instead of class). The current Smart Format parser operators in my project are ., which seems like it should be able to handle the evaluations unless I’m missing something(obviously, I am somewhere)? At this point, I’m not sure what needs to be added to properly evaluate the string interpolation, or if what I’m trying would even work.
Even tried using the ‘dumb string’ version and modifying that in code to try and make that work, but no luck there either.
Using the string as a direct call from script lets me return the requested data as expected, but of course it bypasses localization entirely that way.
All I really want is to be able to reference the interpolated string from a table like any other localized string and have it get the value like it does in the script based direct call.
I feel like I’m missing something very simple here but have no idea what it is and my brain has melted from beating my stubborn head against this for far too long. Have not tried calling it in global or persistent variables yet, seems like I’d likely just end up in the same spot until I can understand why it’s failing now.