c1_unity/Assets/Scripts/Common/SDK/SDKManager.cs
2023-08-14 17:08:25 +08:00

126 lines
4.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using System;
using UnityEngine;
// using BF.UNet.Utility;
// using BF.NativeCore.Platform;
namespace BF
{
// [System.Serializable]
// public class ReqVsn
// {
// public string vsn;
// public string appName;
// public int sid;
// public ReqVsn(string vsn, string appName, int sid)
// {
// this.vsn = vsn;
// this.appName = appName;
// this.sid = sid;
// }
// // public ReqVsn(UNetUtility.ReqVsn reqVsn)
// // {
// // appName = reqVsn.appName;
// // sid = reqVsn.sid;
// // vsn = reqVsn.vsn;
// // }
// }
// [System.Serializable]
// public class RspVsn
// {
// /// <summary>
// /// 是否请求成功
// /// </summary>
// public bool isSuccess;
// /// <summary>
// /// 请求失败后的错误消息;成功时,没有此消息
// /// </summary>
// public string errorMsg;
// public string vsn;
// public List<string> cdnUrl;
// public string md5;
// public string storeUrl;
// // public RspVsn(UNetUtility.RspVsn rspVsn)
// // {
// // isSuccess = rspVsn.isSuccess;
// // errorMsg = rspVsn.errorMsg;
// // vsn = rspVsn.vsn;
// // cdnUrl = rspVsn.cdnUrl;
// // md5 = rspVsn.md5;
// // storeUrl = rspVsn.storeUrl;
// // }
// }
public class SDKManager : ManagerBase
{
//新版本登陆,支付,第三方辅助SDK
public BFLoginSDKManager BFLoginSDKMgr { get; private set; }
public BFPaySDKManager BFPaySDKMgr { get; private set; }
public IAPManager IosPaySDKMgr { get; private set; }
// public BFAdmobSDKManager BFAdmobSDKMgr { get; private set; }
public BFIronSourceSDKManager BFIronSourceSDKMgr { get; private set; }
public BFNativeSDKManager BFNativeSDKMgr { get; private set; }
public BFThirdReportSDKManager BFThirdReportSDKMgr { get; private set; }
static SDKManager instance;
public static SDKManager Create()
{
BFLog.LogAssert(instance == null, "This method only allows BFMain to call once");
instance = new SDKManager();
return instance;
}
SDKManager() { }
public override void Init()
{
base.Init();
//初始化SDK部分
var sdkGo = UnityEngine.GameObject.Find("SDKManager");
if (sdkGo == null)
{
sdkGo = new GameObject("SDKManager");
}
// 登陆
BFLoginSDKMgr = sdkGo.AddComponent<BFLoginSDKManager>();
// 支付
BFPaySDKMgr = sdkGo.AddComponent<BFPaySDKManager>();
// 广告
// BFAdmobSDKMgr = sdkGo.AddComponent<BFAdmobSDKManager>();
BFIronSourceSDKMgr = sdkGo.AddComponent<BFIronSourceSDKManager>();
// 三方上报
BFThirdReportSDKMgr = sdkGo.AddComponent<BFThirdReportSDKManager>();
// native交互管理
BFNativeSDKMgr = sdkGo.AddComponent<BFNativeSDKManager>();
IosPaySDKMgr = IAPManager.Instance;
GameObject.DontDestroyOnLoad(sdkGo);
}
public override void Destroy()
{
base.Destroy();
instance = null;
}
/// <summary>
/// 返回当前系统语言格式为语言码_地区码例如: zh_CN
/// 语言码和国家/地区码当前系统都是返回的二位码
/// 语言码 https://omegat.sourceforge.io/manual-latest/zh_CN/appendix.languages.html
/// 国家/地区码 http://www.mohrss.gov.cn/SYrlzyhshbzb/zhuanti/jinbaogongcheng/Jbgcbiaozhunguifan/201112/t20111206_47429.html
/// </summary>
public string GetLanguage()
{
return NativeUtils.GetLanguageAndCountry();
}
public string GetTimeZone()
{
return NativeUtils.GetTimeZone();
}
}
}