Building to Web GL fails EVERY TIME. What am I doing wrong?
I'm trying to build a text adventure game that I wrote about 3 years ago to WebGL, and it simply will not build. If I build to WebAssembly it will run for about an hour before asm2wasm.exe crashes. If I build to asm.js then it will run for a long time, then simply disappear as though it is complete, but nothing at all is created in the build folder. Unity doesn't even give me the courtesy of spitting an error at me.
Naturally, I tried it on other machines (3 of them), but with the same results. I've also tried an older version of Unity. So far I've tried 2018.1.9, 2018.2.2, and 2018.2.5. The game runs flawlessly in the editor.
I thought maybe it was an issue with converting 12,000+ lines of C# to java (it's a long game), so I made a fresh "game" from scratch that simply contains 1 scene, 1 small PNG asset, and 1 script (below), but the results are the same.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextController : MonoBehaviour {
private enum States {
Start, State1, State2, State3a, State3b, State3c, State3d, State4, State5, State6, State7
}
public Text text;
private bool haveKey = false;
private States state;
private int keyTimer;
// Use this for initialization
void Start () {
state = States.Start;
}
// Update is called once per frame
void Update () {
keyTimer -=1;
if (state == States.Start) {stateStart(); }
if (state == States.State1) {stateState1(); }
if (state == States.State2) {stateState2(); }
if (state == States.State3a) {stateState3a(); }
if (state == States.State3b) {stateState3b(); }
if (state == States.State3c) {stateState3c(); }
if (state == States.State3d) {stateState3d(); }
if (state == States.State4) {stateState4(); }
if (state == States.State5) {stateState5(); }
if (state == States.State6) {stateState6(); }
if (state == States.State7) {stateState7(); }
}
#region States
void stateStart(){
text.text = "This is the starting state.\n\n\n\nPress Enter to begin.";
if (Input.GetKeyDown(KeyCode.KeypadEnter) && keyTimer <=0) {keyTimer = 20; state = States.State1; }
}
void stateState1(){
text.text = "This is State 1.\n\n\n\nPress 1 to go to State 2.\nPress 2 to go to State 3.";
if (Input.GetKeyDown(KeyCode.Keypad1) && keyTimer <=0) {keyTimer = 20; state = States.State2; }
else if (Input.GetKeyDown(KeyCode.Keypad2) && keyTimer <=0) {keyTimer = 20; state = States.State3a; }
}
void stateState2(){
text.text = "This is State 2, which only connects to State 1.\n\n\n\nPress Enter to return to State 1.";
if (Input.GetKeyDown(KeyCode.KeypadEnter) && keyTimer <=0){keyTimer = 20; state = States.State1; }
}
void stateState3a(){
text.text = "This is State 3a. A key is required to move to State 4.\n\n\n\nPress 1 to go to State 4.\nPress 2 to collect the key.";
if (Input.GetKeyDown(KeyCode.Keypad1) && keyTimer <=0) {keyTimer = 20; state = States.State3b; }
else if (Input.GetKeyDown(KeyCode.Keypad2) && keyTimer <=0) {keyTimer = 20; state = States.State3c; }
}
void stateState3b(){
text.text = "This is State 3b, which exists to tell you that you cannot progress to State 4 without the key.\n\n\n\nPress Enter to return to State 3a.";
if (Input.GetKeyDown(KeyCode.KeypadEnter) && keyTimer <=0){keyTimer = 20; state = States.State3a; }
}
void stateState3c(){
text.text = "This is State 3c. You have collected the key.\n\n\n\nPress Enter to go to State 3d.";
if (Input.GetKeyDown(KeyCode.KeypadEnter) && keyTimer <=0){keyTimer = 20; state = States.State3d; }
}
void stateState3d(){
text.text = "This is State 3d. You have the key to State 4.\n\n\n\nPress Enter to go to State 4.";
if (Input.GetKeyDown(KeyCode.KeypadEnter) && keyTimer <=0){keyTimer = 20; state = States.State4; }
}
void stateState4(){
text.text = "This is the State 4.\n\n\n\nPress 1 to go to State 5.\nPress 2 to go to State 6.";
if (Input.GetKeyDown(KeyCode.Keypad1) && keyTimer <=0) {keyTimer = 20; state = States.State5; }
else if (Input.GetKeyDown(KeyCode.Keypad2) && keyTimer <=0) {keyTimer = 20; state = States.State6; }
}
void stateState5(){
text.text = "This is the State 5.\n\n\n\nPress 1 to go to State 6.\nPress 2 to return to State 4.";
if (Input.GetKeyDown(KeyCode.Keypad1) && keyTimer <=0) {keyTimer = 20; state = States.State6; }
else if (Input.GetKeyDown(KeyCode.Keypad2) && keyTimer <=0) {keyTimer = 20; state = States.State4; }
}
void stateState6(){
text.text = "This is State 6.\n\n\n\nPress Enter to go to State 7.";
if (Input.GetKeyDown(KeyCode.KeypadEnter) && keyTimer <=0){keyTimer = 20; state = States.State7; }
}
void stateState7(){
text.text = "This is the State 7. There are no more states\n\nGame Over.\n\n\n\nPress Enter to restart.";
if (Input.GetKeyDown(KeyCode.KeypadEnter) && keyTimer <=0){keyTimer = 20; state = States.Start; }
}
#endregion
}
What am I doing wrong?
Just fully uninstalled Unity, reinstalled, and tried to build an even simpler code program. One that does nothing more than fade transparency on a small png.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScreenFade : $$anonymous$$onoBehaviour {
public Image img;
private IEnumerator ScreenFader(){
for (float i = 1; i >= 0; i -= Time.deltaTime)
{
// set color with i as alpha
img.color = new Color(1, 1, 1, i);
yield return null;
}
Debug.Log("Fade-in complete");
}
void Start () {
img.color = new Color(1, 1, 1, 0);
StartCoroutine(ScreenFader());
}
}
Ran for almost half an hour, then asm2wasm.exe crashed with the following:
Problem signature: Problem Event Name: APPCRASH Application Name: asm2wasm.exe Application Version: 0.0.0.0 Application Timestamp: 5a8aaf6a Fault $$anonymous$$odule Name: asm2wasm.exe Fault $$anonymous$$odule Version: 0.0.0.0 Fault $$anonymous$$odule Timestamp: 5a8aaf6a Exception Code: c0000005 Exception Offset: 0000000000054488 OS Version: 6.1.7601.2.1.0.768.3 Locale ID: 1033 Additional Information 1: 8dc2 Additional Information 2: 8dc2fd2a632b17b6743a9504be473b6a
Additional Information 3: 3ed5
Additional Information 4: 3ed525bcd92b42f2d055b442df8ff8c3Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt