local Platform = {} local bfGateInfo = CS.BF.BFPlatform.GetCurrentGateInfo() Platform.bfGateInfo = bfGateInfo ---- 获取包名 function Platform:getIdentifier() return CS.UnityEngine.Application.identifier end ---- 是否是内网包 function Platform:getIsDevChannel() return CS.BF.BFPlatform.IsDevChannel() end ---- 是否是release包 function Platform:getIsReleaseChannel() return CS.BF.BFPlatform.IsReleaseChannel() end ---- 是否是发布渠道 function Platform:getIsPublishChannel() return CS.BF.BFPlatform.IsPublishChannel() end ---- 获取主链接域名 function Platform:getMainDomain() return bfGateInfo.mainDomain end ---- 获取主链接端口 function Platform:getMainPort() return bfGateInfo.mainPort end -- 平台 function Platform:getPlatform() if self._platform then return self._platform end if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then self._platform = "Android" elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer then self._platform = "iOS" elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.OSXEditor then self._platform = "Mac" elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.OSXPlayer then self._platform = "Mac" elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor then self._platform = "Windows" elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer then self._platform = "Windows" else self._platform = "Unknow" end return self._platform end -- 获取当前版本号 function Platform:getClientVersion() if self.clientVersion == nil then self.clientVersion = CS.BF.BFMain.Instance.GameLaunchMgr:GetCurrentVersion() end return self.clientVersion end -- 获取并处理当前版本号 例:1.3.2 => 1*1000000 + 3 * 1000 + 2 = 1003002 function Platform:getClientVersionNum() local version = Platform:getClientVersion() local versionStrs = string.split(version, ".") local versionNum1 = tonumber(versionStrs[1]) local versionNum2 = tonumber(versionStrs[2]) local versionNum3 = tonumber(versionStrs[3]) return versionNum1 * 1000000 + versionNum2 * 1000 + versionNum3 end function Platform:isIosPlatform() return self:getPlatform() == "iOS" end function Platform:isAndroidPlatform() return self:getPlatform() == "Android" end -- 联网需求后端需要的平台字符串 function Platform:getPlatformStr() if self.platformStr == nil then if self:isIosPlatform() then self.platformStr = "iOS" elseif self:isAndroidPlatform() then self.platformStr = "Android" else self.platformStr = "Unity" end end return self.platformStr end return Platform