From f0be76c0ce2e072982a35af8c904f00e987e8e99 Mon Sep 17 00:00:00 2001 From: walon Date: Mon, 18 May 2026 22:29:44 +0800 Subject: [PATCH] fix: correct conditional compilation macro for Windows standalone targeting Fixes an issue where 'UNITY_STANDALONE_WIN' is incorrectly defined when building or targeting Windows standalone from a non-Windows Unity Editor (e.g., macOS/Linux). This caused the Editor to incorrectly hit the Windows code path (kernel32.dll / VirtualProtect) instead of the POSIX one, leading to compilation errors or runtime crashes during the build process. --- Editor/3rds/UnityHook/HookUtils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Editor/3rds/UnityHook/HookUtils.cs b/Editor/3rds/UnityHook/HookUtils.cs index 07a5e5e..7a5b8b0 100644 --- a/Editor/3rds/UnityHook/HookUtils.cs +++ b/Editor/3rds/UnityHook/HookUtils.cs @@ -50,7 +50,7 @@ namespace MonoHook if (ptr == IntPtr.Zero) return; -#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN +#if UNITY_EDITOR_WIN || (!UNITY_EDITOR && UNITY_STANDALONE_WIN) uint oldProtect; bool ret = VirtualProtect(ptr, (uint)size, Protection.PAGE_EXECUTE_READWRITE, out oldProtect); UnityEngine.Debug.Assert(ret); @@ -223,7 +223,7 @@ namespace MonoHook }; -#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN +#if UNITY_EDITOR_WIN || (!UNITY_EDITOR && UNITY_STANDALONE_WIN) [Flags] public enum Protection {