提交 2e1f623b 编写于 作者: E Elie Bariche

perf: Add Magnetometer.DispatchReading export

上级 2207ef9f
......@@ -17,7 +17,11 @@ namespace Windows.Devices.Sensors {
public static initialize(): boolean {
try {
if (typeof window.Magnetometer === "function") {
this.dispatchReading = (<any>Module).mono_bind_static_method("[Uno] Windows.Devices.Sensors.Magnetometer:DispatchReading");
if ((<any>globalThis).DotnetExports !== undefined) {
this.dispatchReading = (<any>globalThis).DotnetExports.Uno.Windows.Devices.Sensors.Magnetometer.DispatchReading;
} else {
this.dispatchReading = (<any>Module).mono_bind_static_method("[Uno] Windows.Devices.Sensors.Magnetometer:DispatchReading");
}
let MagnetometerClass: any = window.Magnetometer;
this.magnetometer = new MagnetometerClass({ referenceFrame: 'device' });
return true;
......
......@@ -5,6 +5,8 @@ using Uno;
using Uno.Devices.Sensors.Helpers;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.JavaScript;
using NativeMethods = __Windows.Devices.Sensors.Magnetometer.NativeMethods;
#endif
......@@ -70,6 +72,9 @@ namespace Windows.Devices.Sensors
/// <param name="y">Magnetic field Y</param>
/// <param name="z">Magnetic field Z</param>
/// <returns>0 - needed to bind method from WASM</returns>
#if NET7_0_OR_GREATER
[JSExport]
#endif
public static int DispatchReading(float x, float y, float z)
{
if (_instance == null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册