Closed NicolasAvatar closed 4 months ago
Hi @NicolasAvatar,
Your suggestion points to generate a different output binary using compilation directives like UNITY_EDITOR or UNITY_64. That doesn't seem to be a universal approach but ad-hoc for your particular needs.
We can implement only a universal solution. That implies to detect Unity at runtime, by any means.
I haven't seen a straightforward approach, but maybe we can detect certain class at runtime, probably "UnityEngine.Application". Can you research on that?
Closing this one as we don't have more feedback. We cannot test Unity by our own neither it is an expected environment.
In case somebody wants to contribute, here is a Unity detection code: https://github.com/grpc/grpc/blob/2ebd3c3c02a986a377680209e2ad9c6f10c69032/src/csharp/Grpc.Core/Internal/PlatformApis.cs
Bug description Since the validation of processor architecture in addition to the operating system, we cannot use fo-dicom.Codecs in Unity because the test is not owrking in the Mono environment there. Possibly related to https://github.com/Efferent-Health/fo-dicom.Codecs/issues/62
To Reproduce Invoke FellowOakDicom.Imaging.NativeCodec.DicomJpegLsNativeCodec.Decode method with a Jpeg encoded DICOM in Unity, it will throw an Unsupported OS Platform exception.
Explanation In .NET everything works fine, but in Unity Platform.Current property returns Platform.Type.unsupported even if we're on Windows 64, so the Decode method throws immediately:
And the reason why Platform.Current is unsupported is because in Unity environment the ProcessorArchitecture value is ProcessorArchitecture.MSIL, instead of expected ProcessorArchitecture.Amd64, in the Platform.getCurrentType method feeding this property:
![image](https://github.com/Efferent-Health/fo-dicom.Codecs/assets/99667494/3846ce14-f493-45d0-a6c1-c1682b19db5c)
Possible fix Find below the fix I'm applying to make this work in Unity and Windows environment:
Environment:
fo-dicom
nuget package version: 5.1.1fo-dicom.Codecs
nuget package version: 5.10.8