using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using System;
|
using LitJson;
|
|
public class SDKCallBack : MonoBehaviour
|
{
|
public static SDKCallBack ins;
|
public List<Action> list_Action = new List<Action>();
|
public List<string> list_callBackName = new List<string>();
|
public Dictionary<string, Action> dic = new Dictionary<string, Action>();
|
|
public void Awake()
|
{
|
ins = this;
|
SDKManager.ins.sdk.setCallBackClazz("SDKCallBack", "AndroidCallBack");
|
// 在这里开始初始化SDK
|
SDKManager.ins.sdk.initSdk();
|
}
|
|
|
public void setNextAction(string act,Action func)
|
{
|
if (!dic.ContainsKey(act))
|
{
|
dic.Add(act, func);
|
}
|
}
|
|
// 安卓所有的回调方法都通过这里通知Unity
|
public void AndroidCallBack(string arg)
|
{
|
Debug.Log("安卓返回值===>"+arg);
|
JsonData data = JsonMapper.ToObject(arg);
|
//loginData = JsonMapper.ToObject(value);
|
|
if (data.ContainsKey("action"))
|
{
|
string act = data["action"].ToString();
|
Debug.Log(act);
|
if(act == "login")
|
{
|
LoginResult(act);
|
}
|
}
|
|
}
|
|
void LoginResult(string act)
|
{
|
Action func = dic[act];
|
func?.Invoke();
|
}
|
|
void Chongzhi()
|
{
|
|
}
|
|
// Start is called before the first frame update
|
void Start()
|
{
|
}
|
|
// Update is called once per frame
|
void Update()
|
{
|
|
}
|
}
|