'Unity3D - Static Action not triggered in WEBGL
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));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
