Prevent non-Windows system trying to initialize WindowsPointerHandler.

This commit is contained in:
2023-02-05 15:58:31 +08:00
parent 404a36f9b8
commit 596c6395e4

View File

@@ -31,6 +31,8 @@ namespace Cryville.Common.Unity.Input {
public WindowsPointerHandler() {
if (Instance != null)
throw new InvalidOperationException("WindowsPointerHandler already created");
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
throw new NotSupportedException("Windows pointer is not supported on this device");
Instance = this;
usePointerMessage = true;
@@ -142,9 +144,11 @@ namespace Cryville.Common.Unity.Input {
}
public override void Dispose(bool disposing) {
Deactivate();
if (usePointerMessage)
NativeMethods.EnableMouseInPointer(false);
if (disposing) {
Deactivate();
if (usePointerMessage)
NativeMethods.EnableMouseInPointer(false);
}
Instance = null;
}