| | |
| | | |
| | | public void Awake() |
| | | { |
| | | ins = this; |
| | | SDKManager.ins.sdk.setCallBackClazz("SDKCallBack", "AndroidCallBack"); |
| | | // 在这里开始初始化SDK |
| | | SDKManager.ins.sdk.initSdk(); |
| | | } |
| | | |
| | | if (ins) |
| | | { |
| | | Destroy(gameObject); |
| | | } |
| | | else |
| | | { |
| | | ins = this; |
| | | DontDestroyOnLoad(this); |
| | | if (KTGMGemClient.GameConfig.useSDK) |
| | | { |
| | | Debug.Log("安卓SDK初始化"); |
| | | SDKManager.ins.sdk.setCallBackClazz("SDKCallBack", "AndroidCallBack"); |
| | | // 在这里开始初始化SDK |
| | | SDKManager.ins.sdk.initSdk(); |
| | | } |
| | | |
| | | public void setNextAction(string act,Action func) |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public void setNextAction(string act, Action func) |
| | | { |
| | | if (!dic.ContainsKey(act)) |
| | | { |
| | |
| | | // 安卓所有的回调方法都通过这里通知Unity |
| | | public void AndroidCallBack(string arg) |
| | | { |
| | | Debug.Log("安卓返回值===>"+arg); |
| | | Debug.Log("安卓返回值===>" + arg); |
| | | JsonData data = JsonMapper.ToObject(arg); |
| | | //loginData = JsonMapper.ToObject(value); |
| | | |
| | | if (data.ContainsKey("action")) |
| | | { |
| | | // data.data.openid |
| | | // { "code":200,"msg":"success","data":{ "is_certify":0,"age":0,"openid":"1000484"} } |
| | | |
| | | //{ "action":"login", "data":{ "code":200,"msg":"success","data":{ "is_certify":0,"age":0,"openid":"1000485"} } } |
| | | string act = data["action"].ToString(); |
| | | Debug.Log(act); |
| | | if(act == "login") |
| | | if (act == "login") |
| | | { |
| | | LoginResult(act); |
| | | JsonData loginData = data["data"]; |
| | | if ((int)loginData["code"] == 200) |
| | | { |
| | | if (loginData.ContainsKey("msg")) |
| | | { |
| | | string result = loginData["msg"].ToString(); |
| | | if (result.Equals("success")) |
| | | { |
| | | Debug.Log("成功了"); |
| | | } |
| | | else |
| | | { |
| | | Debug.Log("失败了"); |
| | | |
| | | } |
| | | } |
| | | |
| | | string uid = loginData["data"]["openid"].ToString(); |
| | | SDKManager.ins.sdk.uid = (string)uid; |
| | | LoginResult(act); |
| | | } |
| | | else |
| | | { |
| | | // 登录失败则直接重新拉起 |
| | | SDKManager.ins.sdk.login(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | void LoginResult(string act) |
| | |
| | | |
| | | void Chongzhi() |
| | | { |
| | | |
| | | |
| | | } |
| | | |
| | | // Start is called before the first frame update |
| | |
| | | // Update is called once per frame |
| | | void Update() |
| | | { |
| | | |
| | | |
| | | } |
| | | } |