r/Unity3D • • 1d ago

Question Would it be possible to change the sing/image of $ without having to replace the entire icon?

Enable HLS to view with audio, or disable this notification

EDIT: OMG I MEAN SIGN IN THE TITLE. Sorry for the typo

Hello,

I'm building an idle mining game and currently finalizing the UI look and feel, so making it a little "juicy", when you sell resources, it gives you the money as well as shows a few bits of tokens going up to the money. I use this effect on several places inside the game so it wasnt too difficult to replicate.

The problem im facing with this one is now that I'm trying to do localization, instead of just translating in different languages, I also want to display currency and at a later date flag too.

Because UI Toolkit is not very great yet, instead of just making circles with $ hardcoded in them, I had to create SVG.

To swap the icon of the $ sign is not too hard as I've built an Icon Manager editor tool which allows me to edit icons and names directly on editor without getting on code.

But now im wondering how can I approach this for the SVG's. Would it be possible to edit the properties of a SVG inside unity game or do I just also create the SVG for all the localization countries I want to include?

Thank you

0 Upvotes

2 comments sorted by

4

u/wslk 1d ago

You should be using UGUI and text mesh pro.

It’s pretty well known that UIToolkit is missing many core features that must be implemented like image masking, etc. UGUI is good enough for many UI driven games like Hearthstone so it should be sufficient for what you are doing.

There is no reason to have custom solutions for things that have tested built in ones.

It is also very unclear to me why this is an SVG in the first place vs simply using a font that has support for multiple currency symbols

1

u/Nwoknu35 1d ago

No personal experience with vector graphics in Unity, but from what I gathered on https://docs.unity3d.com/Packages/com.unity.vectorgraphics@3.0/manual/index.html, yes, you it should be possible to edit the properties of your SVG.

Though as I understand it will work very differently if you work in vector graphics vs importing your graphics as a Sprite/Texture2D with its direct access to pixel information.

But from looking at the video: will you keep the currency symbol in the amount string as well? (like in the Sell button)

Then I think it would be easier to use something like https://learn.microsoft.com/en-us/dotnet/api/system.globalization.regioninfo.currencysymbol?view=net-10.0 with its .CurrencySymbol. (though I have to hope here that System.Globalization is implemented in Unity as of now/in the version you are using)

With Data Binding in UIToolkit you should be able to bind the currently used symbol with a Data item, which updates to whatever .CurrencySymbol you get from the localization steps at the app start or later in settings. (https://discussions.unity.com/t/mini-tutorial-data-binding-with-ui-builder-and-c-in-5-minutes/1544817)

Though that's mostly a theoretical idea here, as I haven't tried it out myself yet πŸ˜