🤑 Indie game store🙌 Free games😂 Fun games😨 Horror games
👷 Game development🎨 Assets📚 Comics
🎉 Sales🎁 Bundles

[solved] Null reference error when adding Super Text Mesh component in script

A topic by Saafris created 19 days ago Views: 19 Replies: 1
Viewing posts 1 to 2
(Edited 1 time)


Was playing around with Super Text Mesh and working on adding text to the screen through a simple script.

Ran into an odd bug that I wasn't sure what was causing it. If I manually add the STM component to a game object, it acts fine and shows up correctly. But if I add a STM component through code it does the following:

1. It does not display at all, and it logs 2-3 identical errors about a null reference.

2. If I go into the inspector and select the game object that has the STM component attached, the text will begin rendering as error pink boxes.

3. If I disable and re-enable that component, it will begin rendering correctly.

Below are those 3 situations, and then my code that adds it to a game object (which is a child game object to something else)
What is the correct way to create a STM text object through scripts, or am I doing it correctly and maybe something has gone wrong with my STM package? Thanks!

Before selecting gameobject

After selecting gameobject

Disable and reenable


I've seen this error pop up before, butnever actually cause any issues until now. This helped pinpoint it!

Adding "if(onCompleteEvent != null)" before the code on line 1121 seems to make everything work fine!

I'll publish the patch shortly!