local Platform = {} ---- 获取包名 function Platform:getIdentifier() if not Platform:getIsPublishChannel() and VersionCompatible:supportSimulatedPackageName() then return CS.BF.BFMain.DPPackageName end return CS.UnityEngine.Application.identifier end ---- 是否是内网开发包 function Platform:getIsDevChannel() return IS_DEV end ---- 是否是外网测试包 function Platform:getIsTestChannel() return IS_TEST end ---- 是否是正式发布包 function Platform:getIsPublishChannel() return IS_PUBLISH 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 -- 判断是否是T3地区 function Platform:getPlatformIsT3() local systemLanguage = CS.UnityEngine.Application.systemLanguage local isAndroid = self:isAndroidPlatform() local isT3 = false -- 测试模式打开 if EDITOR_MODE then return true end -- 需要Android 且 T3地区 才会开放,目前按照系统语言来处理 if isAndroid then -- 除美国、日本、韩国、台湾、德国、法国、英国、加拿大、澳大利亚以外的的地区为T3。 isT3 = true if systemLanguage == CS.UnityEngine.SystemLanguage.English then -- 英语(美国/英国/加拿大/澳大利亚) isT3 = false elseif systemLanguage == CS.UnityEngine.SystemLanguage.Japanese then -- 日语(日本) isT3 = false elseif systemLanguage == CS.UnityEngine.SystemLanguage.Korean then -- 韩语(韩国) isT3 = false elseif systemLanguage == CS.UnityEngine.SystemLanguage.ChineseTraditional then -- 繁体(台湾) isT3 = false elseif systemLanguage == CS.UnityEngine.SystemLanguage.German then -- 德语(德国) isT3 = false elseif systemLanguage == CS.UnityEngine.SystemLanguage.French then -- 法语(法国/加拿大) isT3 = false end else return false end return isT3 end function Platform:getPlatformIsThirdPay() local systemLanguage = CS.UnityEngine.Application.systemLanguage local isAndroid = self:isAndroidPlatform() local isThirdPay = false -- unity模式 并且是越南语的 情况下 打开三方支付 if EDITOR_MODE and I18N:getCurLanguage() == GConst.LANGUAGE.VIETNAMESE then return true end if isAndroid and not CS.BF.BFMain.IsShenhe then -- if systemLanguage == CS.UnityEngine.SystemLanguage.Russian then -- isThirdPay = true -- end -- if self:getIdentifier() == "" then -- isThirdPay = true -- end end return isThirdPay end function Platform:getAdvertisingID() if not self.advertisingID then self.advertisingID = "none" -- self.advertisingID = CS.BF.AdvertisingIDManager.GetAdvertisingID() end return self.advertisingID end return Platform