Unity3D - WEBGL 中未触发静态动作
当我在 WebGL 上运行应用程序时,我遇到了一个未触发的事件。它在 Unity 编辑器中工作得很好,但在浏览器上,不会调用操作的订阅方法。如果我能得到一些帮助,那就太好了。
这是动作类
public static class RestAction
{
public static Action<double, double> OnSpinDataReadyToSend;
public static Action<SlotPlayer> OnSlotMachineReady;
}
Where it is being invoked
public class GameController
{
void Start()
{
RestAction.OnSlotMachineReady?.Invoke(this.MPlayer);
}
}
And then, the concerned methods
private void OnEnable()
{
RestAction.OnSlotMachineReady += getPlayerInfo;
SlotPlayer.ChangeCoinsEvent += UpdateBalance;
}
private void OnDisable()
{
SlotPlayer.ChangeCoinsEvent -= UpdateBalance;
RestAction.OnSlotMachineReady -= getPlayerInfo;
}
private void getPlayerInfo(SlotPlayer player)
{
this.MPlayer = player;
Debug.Log("player number = "+PlayerPrefs.GetString(Player.PlayerKey));
StartCoroutine(RestClient.Instance.GetPlayerInfo(PLAYER_INFO,PlayerPrefs.GetString(Player.PlayerKey),player.webAPIUpdateCoins));
}
private void UpdateBalance(int coins)
{
Debug.LogWarning("coins : "+coins);
StartCoroutine(RestClient.Instance.SendSpinData(WEB_URL,coins,randomCallback));
}
I'm stuck with an event not triggered when I run an app on WebGL. It works pretty well when within the Unity Editor, but on browser subscribed methods to the Action aren't being called. Would really nice if I may have some helps.
Here is the Action Class
public static class RestAction
{
public static Action<double, double> OnSpinDataReadyToSend;
public static Action<SlotPlayer> OnSlotMachineReady;
}
Where it is being invoked
public class GameController
{
void Start()
{
RestAction.OnSlotMachineReady?.Invoke(this.MPlayer);
}
}
And then, the concerned methods
private void OnEnable()
{
RestAction.OnSlotMachineReady += getPlayerInfo;
SlotPlayer.ChangeCoinsEvent += UpdateBalance;
}
private void OnDisable()
{
SlotPlayer.ChangeCoinsEvent -= UpdateBalance;
RestAction.OnSlotMachineReady -= getPlayerInfo;
}
private void getPlayerInfo(SlotPlayer player)
{
this.MPlayer = player;
Debug.Log("player number = "+PlayerPrefs.GetString(Player.PlayerKey));
StartCoroutine(RestClient.Instance.GetPlayerInfo(PLAYER_INFO,PlayerPrefs.GetString(Player.PlayerKey),player.webAPIUpdateCoins));
}
private void UpdateBalance(int coins)
{
Debug.LogWarning("coins : "+coins);
StartCoroutine(RestClient.Instance.SendSpinData(WEB_URL,coins,randomCallback));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论