I’ve just created a WebGL build for my puzzle game in Unity. Whilst the Window version worked just fine. I encountered a bug on the web when it can not load the next level when you collided with the goal. Here 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;
}
}
btw here the Itch.io link: https://nathanmakegame.itch.io/dungeon-escape
What are the keywords that i could search to fix this problem and how can i debug it? Thanks for all helps