I looks like some event handling engine code is getting stripped out in the build process but I’m unclear what.
I have an button that should open a new window and change scene. To avoid the browser popup blocker I use the following js plugin
var OpenWindowPlugin = {
openWindow: function(link)
{
var url = Pointer_stringify(link);
document.onmouseup = function()
{
window.open(url);
document.onmouseup = null;
}
}
};
mergeInto(LibraryManager.library, OpenWindowPlugin);
Which I trigger using the following event handler
public class OpenQuizButton : MonoBehaviour, IPointerDownHandler , IPointerClickHandler {
public int quizId;
[DllImport(“__Internal”)]
private static extern void openWindow(string url);
public void OnPointerDown(PointerEventData eventData) {
#if !UNITY_EDITOR
openWindow(“…/quiz/?controller=pages&action=home&quiz_id=” + this.quizId);
#endif
}
public void OnPointerClick(PointerEventData eventData) {
Debug.Log(“Change scene”);
SceneManager.LoadScene(“MainMenu”);
}
}
Running in the editor the scene changes as expected. If I test a build with “strip engine code” disabled it correctly opens the link and changes scene. Unfortunately once I enable “strip engine code” it opens the link successfully but doesn’t change scene. The debug output is never printed to the console so it appears that OnPointerClick is never called.
Confusingly, I never get any “Could not produce class” errors in the console indicating it has failed to create an object. Additionally if I replace the call to window.open with console.log everything works as expected (output is logged to the console and it changes scene).