Platform

4/3/2024 Unity3d

WPlatform.platform: Get the current running platform of the app (获取app当前运行平台)

WPlatform.webGLPlatform: Get the webgl running platform (获取webgl运行平台)

If you only care about webgl, you only need to use 'WPlatform.webGLPlatform' in the webgl development process to distinguish

(如果只关心webgl,只需要在webglDev过程中使用‘WPlatform.webGLPlatform’ 区分)

describe
WPlatform.platform Get the system platform, such as: webgl, win app application,(获取系统平台,比如:webgl,win app 应用)
WPlatform.webGLPlatform Get the platform where webgl is located, such as windows, android,(获取webgl 所在平台,比如windows、android)
WPlatform.IsEditor true: unity editor runtime
WPlatform.isMobilePslatform true: mobile

--lua

print(WPlatform.platform,WPlatform.webGLPlatform) --webgle,win
print(WPlatform.platform == Platform.webgl) -- true

if WPlatform.platform == Platform.win then
        print("win")
elseif WPlatform.platform == Platform.webgl then
    print("webgl")
    if WPlatform.webGLPlatform == WebGLPlatform.chromebook  then
        print("webgl","chromebook")
    elseif WPlatform.webGLPlatform == WebGLPlatform.win  then
        print("webgl","win")
    end
end

if WPlatform.IsEditor==true then
    print("this is unity editor runtime")
end

if WPlatform.isMobilePslatform ==true then
	print("this is Mobile") 
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Last Updated: Thu, 03 Apr 2025 08:48:48 GMT