Commit 7c7d31b4 authored by gaorui's avatar gaorui
Browse files

Merge branch 'feat-unity' into 'develop'

feat(app): 调整场景与接口

See merge request unity-cross/UnityDemo!7
parents 274f3796 21f8bf4e
...@@ -159,7 +159,7 @@ RectTransform: ...@@ -159,7 +159,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -1000, y: -450} m_AnchoredPosition: {x: -1000, y: -450}
m_SizeDelta: {x: 240, y: 80} m_SizeDelta: {x: 260, y: 120}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &40919616 --- !u!114 &40919616
MonoBehaviour: MonoBehaviour:
...@@ -339,8 +339,8 @@ MonoBehaviour: ...@@ -339,8 +339,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 30
m_fontSizeBase: 24 m_fontSizeBase: 30
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
...@@ -473,8 +473,8 @@ MonoBehaviour: ...@@ -473,8 +473,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 32
m_fontSizeBase: 24 m_fontSizeBase: 32
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
...@@ -693,7 +693,7 @@ RectTransform: ...@@ -693,7 +693,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -1000, y: 0} m_AnchoredPosition: {x: -1000, y: 0}
m_SizeDelta: {x: 240, y: 80} m_SizeDelta: {x: 260, y: 120}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &165585585 --- !u!114 &165585585
MonoBehaviour: MonoBehaviour:
...@@ -870,7 +870,7 @@ RectTransform: ...@@ -870,7 +870,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -1000, y: 150} m_AnchoredPosition: {x: -1000, y: 150}
m_SizeDelta: {x: 240, y: 80} m_SizeDelta: {x: 260, y: 120}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &259715465 --- !u!114 &259715465
MonoBehaviour: MonoBehaviour:
...@@ -1050,8 +1050,8 @@ MonoBehaviour: ...@@ -1050,8 +1050,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 30
m_fontSizeBase: 24 m_fontSizeBase: 30
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
...@@ -1173,7 +1173,7 @@ RectTransform: ...@@ -1173,7 +1173,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -1000, y: 300} m_AnchoredPosition: {x: -1000, y: 300}
m_SizeDelta: {x: 240, y: 80} m_SizeDelta: {x: 260, y: 120}
m_Pivot: {x: 0.5000001, y: 0.5} m_Pivot: {x: 0.5000001, y: 0.5}
--- !u!114 &633987596 --- !u!114 &633987596
MonoBehaviour: MonoBehaviour:
...@@ -1775,8 +1775,8 @@ MonoBehaviour: ...@@ -1775,8 +1775,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 30
m_fontSizeBase: 24 m_fontSizeBase: 30
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
...@@ -1964,7 +1964,7 @@ GameObject: ...@@ -1964,7 +1964,7 @@ GameObject:
- component: {fileID: 1076467005} - component: {fileID: 1076467005}
- component: {fileID: 1076467004} - component: {fileID: 1076467004}
m_Layer: 0 m_Layer: 0
m_Name: BtnManager m_Name: GameSdkManager
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
...@@ -2034,7 +2034,7 @@ RectTransform: ...@@ -2034,7 +2034,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -1000, y: -300} m_AnchoredPosition: {x: -1000, y: -300}
m_SizeDelta: {x: 240, y: 80} m_SizeDelta: {x: 260, y: 120}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1114040582 --- !u!114 &1114040582
MonoBehaviour: MonoBehaviour:
...@@ -2214,8 +2214,8 @@ MonoBehaviour: ...@@ -2214,8 +2214,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 30
m_fontSizeBase: 24 m_fontSizeBase: 30
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
...@@ -2755,7 +2755,7 @@ RectTransform: ...@@ -2755,7 +2755,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -700, y: 150} m_AnchoredPosition: {x: -700, y: 150}
m_SizeDelta: {x: 240, y: 80} m_SizeDelta: {x: 260, y: 120}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1459490477 --- !u!114 &1459490477
MonoBehaviour: MonoBehaviour:
...@@ -3010,8 +3010,8 @@ MonoBehaviour: ...@@ -3010,8 +3010,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 32
m_fontSizeBase: 24 m_fontSizeBase: 32
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
...@@ -3176,7 +3176,7 @@ RectTransform: ...@@ -3176,7 +3176,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -1000, y: -150} m_AnchoredPosition: {x: -1000, y: -150}
m_SizeDelta: {x: 240, y: 80} m_SizeDelta: {x: 260, y: 120}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1577749885 --- !u!114 &1577749885
MonoBehaviour: MonoBehaviour:
...@@ -3356,8 +3356,8 @@ MonoBehaviour: ...@@ -3356,8 +3356,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 30
m_fontSizeBase: 24 m_fontSizeBase: 30
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
...@@ -3750,8 +3750,8 @@ MonoBehaviour: ...@@ -3750,8 +3750,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 30
m_fontSizeBase: 24 m_fontSizeBase: 30
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
...@@ -3884,8 +3884,8 @@ MonoBehaviour: ...@@ -3884,8 +3884,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 30
m_fontSizeBase: 24 m_fontSizeBase: 30
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
...@@ -3971,7 +3971,7 @@ RectTransform: ...@@ -3971,7 +3971,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -700, y: 450} m_AnchoredPosition: {x: -700, y: 450}
m_SizeDelta: {x: 240, y: 80} m_SizeDelta: {x: 260, y: 120}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1889515971 --- !u!114 &1889515971
MonoBehaviour: MonoBehaviour:
...@@ -4104,7 +4104,7 @@ RectTransform: ...@@ -4104,7 +4104,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -700, y: 300} m_AnchoredPosition: {x: -700, y: 300}
m_SizeDelta: {x: 240, y: 80} m_SizeDelta: {x: 260, y: 120}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1966209685 --- !u!114 &1966209685
MonoBehaviour: MonoBehaviour:
...@@ -4417,8 +4417,8 @@ MonoBehaviour: ...@@ -4417,8 +4417,8 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 24 m_fontSize: 32
m_fontSizeBase: 24 m_fontSizeBase: 32
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
......
fileFormatVersion: 2
guid: 789ca815eac2f468b94840a621f0b2e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -5,6 +5,14 @@ using UnityEngine; ...@@ -5,6 +5,14 @@ using UnityEngine;
public class GameManager : MonoBehaviour public class GameManager : MonoBehaviour
{ {
private void Awake()
{
// 触发单例构造,内部会调用 PlatformCallback.SetListener(this)
var _ = HoolaiListener.Instance;
}
public void OnLoginBtnClicked() public void OnLoginBtnClicked()
{ {
NativeLogger.I("fastsdk_btn_unity", "clicked login"); NativeLogger.I("fastsdk_btn_unity", "clicked login");
...@@ -90,7 +98,7 @@ public class GameManager : MonoBehaviour ...@@ -90,7 +98,7 @@ public class GameManager : MonoBehaviour
{ {
NativeLogger.I("fastsdk_btn_unity", "clicked Pay With First Goods"); NativeLogger.I("fastsdk_btn_unity", "clicked Pay With First Goods");
List<GoodsInfo> goodsList = PlatformCallback.GetCachedGoodsList(); List<GoodsInfo> goodsList = HoolaiListener.Instance.GetCachedGoodsList();
if (goodsList == null || goodsList.Count == 0) if (goodsList == null || goodsList.Count == 0)
{ {
...@@ -141,7 +149,7 @@ public class GameManager : MonoBehaviour ...@@ -141,7 +149,7 @@ public class GameManager : MonoBehaviour
NativeLogger.I("fastsdk_btn_unity", "clicked Pay With Random Goods"); NativeLogger.I("fastsdk_btn_unity", "clicked Pay With Random Goods");
// 获取缓存的商品列表 // 获取缓存的商品列表
List<GoodsInfo> goodsList = PlatformCallback.GetCachedGoodsList(); List<GoodsInfo> goodsList = HoolaiListener.Instance.GetCachedGoodsList();
if (goodsList == null || goodsList.Count == 0) if (goodsList == null || goodsList.Count == 0)
{ {
......
using System;
using System.Collections.Generic;
public class HoolaiListener : IPlatformCallbackListener
{
private static HoolaiListener _instance;
private List<GoodsInfo> _cachedGoodsList;
//商品列表更新事件
public event Action<List<GoodsInfo>> OnGoodsListUpdated;
public static HoolaiListener Instance
{
get
{
if (_instance == null)
{
_instance = new HoolaiListener();
}
return _instance;
}
}
private HoolaiListener()
{
// 自动设置监听器
PlatformCallback.SetListener(this);
}
public void OnInitSuccess(InitResult result)
{
NativeLogger.I("fastsdk_unity_result", $"OnInitSuccess GameId:{result.gameId} channel:{result.channel} channelId:{result.channelId}");
}
public void OnInitFailed(string reason)
{
NativeLogger.I("fastsdk_unity_result", $"OnInitFailed reason:{reason}");
}
public void OnLoginFailed(string reason)
{
NativeLogger.I("fastsdk_unity_result", $"OnLoginFailed reason:{reason}");
}
public void OnLoginSuccess(LoginResult result)
{
NativeLogger.I("fastsdk_unity_result", $"OnLoginSuccess uid:{result.uid} channel:{result.channel} channelId:{result.accessToken}");
}
public void OnRefreshUser(LoginResult result)
{
NativeLogger.I("fastsdk_unity_result", $"OnRefreshUser uid:{result.uid} channel:{result.channel} channelId:{result.accessToken}");
}
public void OnLogout(string message)
{
NativeLogger.I("fastsdk_unity_result", $"OnLogout reason:{message}");
}
public void OnPayFailed(string reason)
{
NativeLogger.I("fastsdk_unity_result", $"OnPayFailed reason:{reason}");
}
public void OnPayGoodsList(List<GoodsInfo> goodsList)
{
_cachedGoodsList = goodsList;
OnGoodsListUpdated?.Invoke(goodsList);
NativeLogger.I("fastsdk_unity_result", $"OnPayGoodsList count:{goodsList?.Count ?? 0}");
}
// 获取缓存的商品列表
public List<GoodsInfo> GetCachedGoodsList()
{
return _cachedGoodsList;
}
public void OnPaySuccess(string message)
{
NativeLogger.I("fastsdk_unity_result", $"OnPaySuccess message:{message}");
}
public void OnShareFailed(string reason)
{
NativeLogger.I("fastsdk_unity_result", $"OnShareFailed reason:{reason}");
}
public void OnShareSuccess(string reason)
{
NativeLogger.I("fastsdk_unity_result", $"OnShareSuccess reason:{reason}");
}
public void OnUpdate(string data)
{
NativeLogger.I("fastsdk_unity_result", $"OnUpdate data:{data}");
}
public void OnCustomExit()
{
NativeLogger.I("fastsdk_unity_result", $"OnCustomExit");
}
}
using System.Collections.Generic;
public interface IPlatformCallbackListener
{
void OnInitSuccess(InitResult result);
void OnInitFailed(string reason);
void OnUpdate(string data);
void OnLoginSuccess(LoginResult result);
void OnLoginFailed(string reason);
void OnRefreshUser(LoginResult result);
void OnLogout(string message);
void OnPayGoodsList(List<GoodsInfo> goodsList);
void OnPaySuccess(string message);
void OnPayFailed(string reason);
void OnShareSuccess(string message);
void OnShareFailed(string reason);
void OnCustomExit();
}
\ No newline at end of file
...@@ -37,9 +37,7 @@ public class GoodsInfo ...@@ -37,9 +37,7 @@ public class GoodsInfo
public class PlatformCallback : MonoBehaviour public class PlatformCallback : MonoBehaviour
{ {
// 添加字段用于保存商品列表 private static IPlatformCallbackListener _listener;
private List<GoodsInfo> _goodsLists;
// 单例实现,确保只有一个接收器实例 // 单例实现,确保只有一个接收器实例
public static PlatformCallback Instance { get; private set; } public static PlatformCallback Instance { get; private set; }
...@@ -64,39 +62,39 @@ public class PlatformCallback : MonoBehaviour ...@@ -64,39 +62,39 @@ public class PlatformCallback : MonoBehaviour
NativeLogger.I("fastsdk_unity_result", "[PlatformCallback] Initialized with GameObject name: " + gameObject.name); NativeLogger.I("fastsdk_unity_result", "[PlatformCallback] Initialized with GameObject name: " + gameObject.name);
} }
public static void SetListener(IPlatformCallbackListener listener)
{
_listener = listener;
}
public void onInitSuccess(string jsonStr) public void onInitSuccess(string jsonStr)
{ {
Debug.Log("Unity onInitSuccess: " + jsonStr);
NativeLogger.I("fastsdk_unity_result", "[AndroidBrigsCall] onInitSuccess called with result: " + jsonStr); NativeLogger.I("fastsdk_unity_result", "[AndroidBrigsCall] onInitSuccess called with result: " + jsonStr);
InitResult result = JsonConvert.DeserializeObject<InitResult>(jsonStr); InitResult result = JsonConvert.DeserializeObject<InitResult>(jsonStr);
if (result != null) if (result != null)
{ {
NativeLogger.I("fastsdk_unity_result", "反序列化成功!"); _listener?.OnInitSuccess(result);
NativeLogger.I("fastsdk_unity_result", "Channel: " + result.channel);
NativeLogger.I("fastsdk_unity_result", "Game ID: " + result.gameId);
NativeLogger.I("fastsdk_unity_result", "Channel ID: " + result.channelId);
} }
} }
public void onInitFailed(string reason) public void onInitFailed(string reason)
{ {
NativeLogger.I("fastsdk_unity_result", "[Unity] onInitFailed called with reason: " + reason); NativeLogger.I("fastsdk_unity_result", "[Unity] onInitFailed called with reason: " + reason);
_listener.OnInitFailed(reason);
} }
//自定义退出界面 //自定义退出界面
public void onCustomExit() public void onCustomExit()
{ {
NativeLogger.I("fastsdk_unity_result", "[Unity] onCustomExit called"); NativeLogger.I("fastsdk_unity_result", "[Unity] onCustomExit called");
_listener?.OnCustomExit();
} }
//预留 //预留
public void onUpdate(string data) public void onUpdate(string data)
{ {
NativeLogger.I("fastsdk_unity_result", "[Unity] onUpdate called with data: " + data); NativeLogger.I("fastsdk_unity_result", "[Unity] onUpdate called with data: " + data);
_listener?.OnUpdate(data);
} }
//登录成功 //登录成功
...@@ -113,9 +111,9 @@ public class PlatformCallback : MonoBehaviour ...@@ -113,9 +111,9 @@ public class PlatformCallback : MonoBehaviour
} }
LoginResult loginResult = JsonConvert.DeserializeObject<LoginResult>(jsonStr); LoginResult loginResult = JsonConvert.DeserializeObject<LoginResult>(jsonStr);
if (loginResult.uid != 0) { if (loginResult.uid != 0)
// 示例:如果接收到特定消息,切换到另一个场景 {
NativeLogger.I("fastsdk_unity_result", $"[Unity] Login successful, uid:{loginResult.uid} channel:{loginResult.channel} channelUid:{loginResult.channelUid} accessToken:{loginResult.accessToken}"); _listener?.OnLoginSuccess(loginResult);
} }
} }
...@@ -134,55 +132,49 @@ public class PlatformCallback : MonoBehaviour ...@@ -134,55 +132,49 @@ public class PlatformCallback : MonoBehaviour
if (loginResult.uid != 0) if (loginResult.uid != 0)
{ {
// 示例:如果接收到特定消息,切换到另一个场景 _listener?.OnRefreshUser(loginResult);
NativeLogger.I("fastsdk_unity_result", $"[Unity] onRefreshUser Login successful, uid:{loginResult.uid} channel:{loginResult.channel} channelUid:{loginResult.channelUid} accessToken:{loginResult.accessToken}");
} }
} }
public void onLoginFailed(string reason) public void onLoginFailed(string reason)
{ {
NativeLogger.I("fastsdk_unity_result", "[Unity] onLoginFailed called with reason: " + reason); NativeLogger.I("fastsdk_unity_result", "[Unity] onLoginFailed called with reason: " + reason);
_listener?.OnLoginFailed(reason);
} }
public void onLogout(string message) public void onLogout(string message)
{ {
NativeLogger.I("fastsdk_unity_result", "[Unity] onLogout called with message: " + message); NativeLogger.I("fastsdk_unity_result", "[Unity] onLogout called with message: " + message);
_listener?.OnLogout(message);
} }
public void onPayGoodsList(string jsonStr) public void onPayGoodsList(string jsonStr)
{ {
Debug.Log("Unity 收到商品列表: " + jsonStr);
NativeLogger.I("fastsdk_unity_result", "[Unity] onPayGoodsList called with message: " + jsonStr); NativeLogger.I("fastsdk_unity_result", "[Unity] onPayGoodsList called with message: " + jsonStr);
//goodsList = JsonConvert.DeserializeObject<List<GoodsInfo>(jsonStr); List<GoodsInfo> goodsLists = JsonConvert.DeserializeObject<List<GoodsInfo>>(jsonStr);
// 方法一:直接解析为List<GoodsInfo> NativeLogger.I("fastsdk_unity_result", "[Unity] onPayGoodsList deserialized, count: " + (goodsLists?.Count ?? 0) + ", listener is null: " + (_listener == null));
_goodsLists = JsonConvert.DeserializeObject<List<GoodsInfo>>(jsonStr); if (_listener == null)
if (_goodsLists != null && _goodsLists.Count!=0)
{ {
NativeLogger.I("fastsdk_unity_result", $"[Unity] onPayGoodsList: {_goodsLists}");
}
}
// 添加方法用于获取保存的商品列表 NativeLogger.I("fastsdk_unity_result", "[Unity] onPayGoodsList called_listener is null");
public static List<GoodsInfo> GetCachedGoodsList() }
{ _listener?.OnPayGoodsList(goodsLists);
return Instance != null ? Instance._goodsLists : null; //if (goodsLists != null && goodsLists.Count!=0)
//{
// _listener?.OnPayGoodsList(goodsLists);
//}
} }
public void onPaySuccess(string jsonStr) public void onPaySuccess(string jsonStr)
{ {
NativeLogger.I("fastsdk_unity_result", $"[Unity] onPaySuccess called {jsonStr}"); NativeLogger.I("fastsdk_unity_result", $"[Unity] onPaySuccess called {jsonStr}");
_listener?.OnPaySuccess(jsonStr);
} }
public void onPayFailed(string reason) public void onPayFailed(string reason)
{ {
NativeLogger.I("fastsdk_unity_result", "[Unity] onPayFailed called with reason: " + reason); NativeLogger.I("fastsdk_unity_result", "[Unity] onPayFailed called with reason: " + reason);
_listener?.OnPayFailed(reason);
} }
...@@ -190,11 +182,13 @@ public class PlatformCallback : MonoBehaviour ...@@ -190,11 +182,13 @@ public class PlatformCallback : MonoBehaviour
public void onShareSuccess(string jsonStr) public void onShareSuccess(string jsonStr)
{ {
NativeLogger.I("fastsdk_unity_result", $"[Unity] onShareSuccess called {jsonStr}"); NativeLogger.I("fastsdk_unity_result", $"[Unity] onShareSuccess called {jsonStr}");
_listener?.OnShareSuccess(jsonStr);
} }
public void onShareFailed(string jsonStr) public void onShareFailed(string jsonStr)
{ {
NativeLogger.I("fastsdk_unity_result", $"[Unity] onShareFailed called {jsonStr}"); NativeLogger.I("fastsdk_unity_result", $"[Unity] onShareFailed called {jsonStr}");
_listener?.OnShareFailed(jsonStr);
} }
} }
fileFormatVersion: 2
guid: ae9e5ac1843c944138202b504167711e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment