using UnityEngine;
using LitJson;
public class GameManager : MonoBehaviour
{
void Update()
{
// 1. 主线程Loop, 需要游戏每隔几帧调用一次
LYWSDKPlatform.Loop();
}
public void CallLYWSDKInitOnGameManager()
{
Debug.Log("---CallLYWSDKInitOnGameManager---");
// 2. 游戏调用初始化接口
LYWSDKPlatform.Init("", new LYWSDKCallBack2GameDelegate(LYWSDKCallBackOnGameManager));
}
public void CallLYWSDKLoginOnGameManager()
{
Debug.Log("---CallLYWSDKLoginOnGameManager---");
// 3. 游戏调用登录接口
LYWSDKPlatform.Login("");
}
public void CallLYWSDKPayOnGameManager()
{
Debug.Log("---CallLYWSDKPayOnGameManager---");
System.Text.StringBuilder sb = new System.Text.StringBuilder();
JsonWriter jw = new JsonWriter(sb);
jw.WriteObjectStart();
jw.WritePropertyName("goodsID");
jw.Write("666666");
jw.WritePropertyName("goodsPrice");
jw.Write("99");
jw.WriteObjectEnd();
// 4. 游戏调用支付接口
LYWSDKPlatform.Pay(sb.ToString());
}
// 5. 游戏接收回调
public static void LYWSDKCallBackOnGameManager(string jsonMessage)
{
Debug.Log("jsonMessage = " + (string.IsNullOrEmpty(jsonMessage) ? "" : jsonMessage));
}
}
using LitJson;
public class GameManager : MonoBehaviour
{
void Update()
{
// 1. 主线程Loop, 需要游戏每隔几帧调用一次
LYWSDKPlatform.Loop();
}
public void CallLYWSDKInitOnGameManager()
{
Debug.Log("---CallLYWSDKInitOnGameManager---");
// 2. 游戏调用初始化接口
LYWSDKPlatform.Init("", new LYWSDKCallBack2GameDelegate(LYWSDKCallBackOnGameManager));
}
public void CallLYWSDKLoginOnGameManager()
{
Debug.Log("---CallLYWSDKLoginOnGameManager---");
// 3. 游戏调用登录接口
LYWSDKPlatform.Login("");
}
public void CallLYWSDKPayOnGameManager()
{
Debug.Log("---CallLYWSDKPayOnGameManager---");
System.Text.StringBuilder sb = new System.Text.StringBuilder();
JsonWriter jw = new JsonWriter(sb);
jw.WriteObjectStart();
jw.WritePropertyName("goodsID");
jw.Write("666666");
jw.WritePropertyName("goodsPrice");
jw.Write("99");
jw.WriteObjectEnd();
// 4. 游戏调用支付接口
LYWSDKPlatform.Pay(sb.ToString());
}
// 5. 游戏接收回调
public static void LYWSDKCallBackOnGameManager(string jsonMessage)
{
Debug.Log("jsonMessage = " + (string.IsNullOrEmpty(jsonMessage) ? "" : jsonMessage));
}
}