- Home /
TextMesh in WebGL
I am meeting an issue when using TextMesh and displaying it on a WebGL build. I got a NullReferenceException and the error message below:
Can't add component because '' is not derived from Component.
However, the text displays properly on the Game view in Unity.
Below is how I created the text object via code.
GameObject textObject = new GameObject ();
textObject.AddComponent<TextMesh> ();
textObject.GetComponent<TextMesh> ().text = text;
textObject.GetComponent<TextMesh> ().color = fontColor;
textObject.transform.parent = parentObject.transform;
Note that I am using 'Screen Space - Camera' on my Canvas, and parentObject is in canvas.
Will appreciate advice. Thanks!
Comment