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 ();
textObject.GetComponent ().text = text;
textObject.GetComponent ().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!
↧