I've just created a WebGL build for my puzzle game in Unity. While the Windows version worked just fine, I encountered a bug on the web: it cannot load the next level when you collide with the goal.
Here is the code:
//PlayerInteraction.cs
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.TryGetComponent(out ReactToPlayer component))
{
component.React(gameObject);
}
}
public class GoalReactToPlayer : ReactToPlayer
{
public override void React(GameObject player)
{
EventBus<WinEvent>.Raise(new WinEvent());
}
}
public class GameController: MonoBehavior
{
private void OnEnable()
{
_winEventBiding = new(WinAction);
EventBus<WinEvent>.Register(_winEventBiding);
}
private async void WinAction(WinEvent @event)
{
await Task.Delay(500);
var a = _sceneTransitioner.LoadNextScene();
a.completed += a => Reload();
}
public class SceneTransitioner : MonoBehaviour
{
public AsyncOperation LoadNextScene()
{
DOTween.KillAll();
int index = SceneManager.GetActiveScene().buildIndex;
var a = SceneManager.LoadSceneAsync(index + 1,LoadSceneMode.Single);
return a;
}
}
How can I debug this?