-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support passing float[] (Single[]) to JS from .NET via [JSImport] #97633
Comments
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsIs there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.I recently tried (and failed) to pass a simple I got it working by casting my floats to doubles using Linq, quite an ugly way which probably could do in a better way: Describe the solution you'd likeIt struck me, if the "workaround" is this simple, why could it not be indirectly supported by the Thoughts? Additional contextNo response
|
cc @pavelsavara |
Indeed, there is duplicate feature request for that. #97380
I found few ways how you can do it here https://stackoverflow.com/questions/69805135/how-does-c-sharp-convert-double-arrays-to-float-arrays-or-int-arrays I guess |
Ok. Thanks, sounds good. I guess your example in my case would be something like |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I recently tried (and failed) to pass a simple
float[]
from .NET to JS. This is obviously not supported, as per the docs:I got it working by casting my floats to doubles using Linq, quite an ugly way which probably could do in a better way:
var myDoubles = myFloats.Select(f => (double)f).ToArray();
passing this to JS works.
Describe the solution you'd like
It struck me, if the "workaround" is this simple, why could it not be indirectly supported by the
[JSImport]
API itself? Either through casting floats to doubles or something more clever? I mean, whatever we can fit in a float, could most definately fit in a double. If you want to explicit then force us to use[JSMarshalAs<JSType.Array<JSType.Number>>]
or something to make it work.Thoughts?
Additional context
No response
The text was updated successfully, but these errors were encountered: