Page 1 of 1

Using doubles in WPF but floats in Unity?

Posted: 20 Jul 2023, 00:22
by Vatyx
I keep running up against the problem of WPF components needing properties to be of type double but the same components in the Noesis Unity integration need floats. Due to how C# is structured I am unable to see a way to coerced floats into doubles and vice versa at runtime without writing #if NOESIS everywhere and defining everything twice. Is there a recommended way to get around this limitation?

Re: Using doubles in WPF but floats in Unity?

Posted: 24 Jul 2023, 12:03
by sfernandez
Hello,

As described here we recommend to define a Float type to handle the double/float difference between WPF and Noesis only once:
#if NOESIS
    using Float = System.Single;
#else
    using Float = System.Double;
#endif

private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<Float> e);
private void UpdateColor(Float r, Float g, Float b, Float a);
Could that work for you?

Re: Using doubles in WPF but floats in Unity?

Posted: 25 Jul 2023, 17:19
by ai_enabled
Hello!
I'm maintaining a fork of "NoesisGUI.Managed" Github repository where I've changed most of the public API to use double instead of float among some other related changes (so WPF applications' code is compatible without any changes).
https://github.com/AtomicTorchStudio/Managed

Regards!

Re: Using doubles in WPF but floats in Unity?

Posted: 03 Aug 2023, 22:18
by Vatyx
Hi, thank you both for the answers.

I didn't see that documentation when going through the docs site. Very useful, thank you!

I'll check out the linked GitHub repro, looks interesting.