File tree 1 file changed +41
-1
lines changed
1 file changed +41
-1
lines changed Original file line number Diff line number Diff line change 1
1
#ifndef UNITYRESOLVE_HPP
2
2
#define UNITYRESOLVE_HPP
3
3
4
- #define WINDOWS_MODE 1 // 如果需要请改为 1 | 1 if you need
4
+ // ============================== 自动检测当前环境 ==============================
5
+
6
+ #if defined(_WIN32) || defined(_WIN64)
7
+ #define WINDOWS_MODE 1
8
+ #else
9
+ #define WINDOWS_MODE 0
10
+ #endif
11
+
12
+ #if defined(__ANDROID__)
13
+ #define ANDROID_MODE 1
14
+ #else
5
15
#define ANDROID_MODE 0
16
+ #endif
17
+
18
+ #if defined(__linux__) && !defined(__ANDROID__)
19
+ #define LINUX_MODE 1
20
+ #else
6
21
#define LINUX_MODE 0
22
+ #endif
23
+
24
+ // ============================== 强制设置当前执行环境 ==============================
25
+
26
+ // #define WINDOWS_MODE 0
27
+ // #define ANDROID_MODE 1 // 设置运行环境
28
+ // #define LINUX_MODE 0
29
+
30
+ // ============================== 导入对应环境依赖 ==============================
7
31
8
32
#if WINDOWS_MODE || LINUX_MODE
9
33
#include < format>
@@ -2899,6 +2923,22 @@ class UnityResolve final {
2899
2923
}
2900
2924
};
2901
2925
2926
+ struct Screen {
2927
+ static auto get_width () -> Int32 {
2928
+ static Method *method;
2929
+ if (!method) method = Get (" UnityEngine.CoreModule.dll" )->Get (" Screen" )->Get <Method>(" get_width" );
2930
+ if (method) return method->Invoke <int32_t >();
2931
+ return 0 ;
2932
+ }
2933
+
2934
+ static auto get_height () -> Int32 {
2935
+ static Method *method;
2936
+ if (!method) method = Get (" UnityEngine.CoreModule.dll" )->Get (" Screen" )->Get <Method>(" get_height" );
2937
+ if (method) return method->Invoke <int32_t >();
2938
+ return 0 ;
2939
+ }
2940
+ };
2941
+
2902
2942
template <typename Return, typename ... Args>
2903
2943
static auto Invoke (void * address, Args... args) -> Return {
2904
2944
#if WINDOWS_MODE
You can’t perform that action at this time.
0 commit comments