Page 1 of 1

Can you change the Unity Noesis default FontSize at runtime?

Posted: 24 Jul 2020, 08:01
by Jamieh
Running under Unity, I've set my Noesis default fontsize to 15px. This works good for our WebAssembly builds, but for tablets we'd like the default fontsize to be bigger.

Maybe a better way to do this would be to just create different styles for tablet/mobile, but I was wondering if there was some way to alter the default fontsize programmatically? Then I could detect the Android or iOS builds and set the default fontsize to 18 in those cases and leave it 15 for our WebAssembly build.

Thanks--if this isn't possible, any other suggestions on how to accomplish this are welcome. Otherwise, I'll just code the default fontsize into every page and alter it in the viewmodel.

Re: Can you change the Unity Noesis default FontSize at runtime?

Posted: 24 Jul 2020, 11:22
by sfernandez
You can call the following code at your application startup to change default font properties.
Noesis.GUI.SetFontDefaultProperties(30.0f, FontWeight.Normal, FontStretch.Normal, FontStyle.Normal);
If a xaml was loaded before executing that code, then that xaml will keep using the values set in Noesis settings.

Another approach could be to use DynamicResources in your control styles to set FontSize, then add to the root xaml the value you want to use depending on the platform:
view.Content.Resources["DefaultFontSize"] = 30.0f;

Re: Can you change the Unity Noesis default FontSize at runtime?

Posted: 24 Jul 2020, 18:39
by Jamieh
Cool, I will try these suggestions. Thanks!