Vatyx
Topic Author
Posts: 9
Joined: 15 May 2023, 22:41

Using doubles in WPF but floats in Unity?

20 Jul 2023, 00:22

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?
 
User avatar
sfernandez
Site Admin
Posts: 3008
Joined: 22 Dec 2011, 19:20

Re: Using doubles in WPF but floats in Unity?

24 Jul 2023, 12:03

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?
 
User avatar
ai_enabled
Posts: 231
Joined: 18 Jul 2013, 05:28
Contact:

Re: Using doubles in WPF but floats in Unity?

25 Jul 2023, 17:19

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!
AtomicTorch Studio Pte. Ltd. http://atomictorch.com
 
Vatyx
Topic Author
Posts: 9
Joined: 15 May 2023, 22:41

Re: Using doubles in WPF but floats in Unity?

03 Aug 2023, 22:18

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.

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests