How to preview text for states?

Is there a way to preview my states to see if the amount of text I write fits in the allocated space?

So far, the Unity game always only shows the basic canvas I’ve set up, and I can’t seem to put up any of the states unless I play the game every time.

Hi,

You could write a new class for testing purposes that simply displays the text. Assign the script to another game object. Add [ExecuteAlways] above the line where you declare the class.

[ExecuteAlways]
public class Test : MonoBehaviour
{
    [SerializeField] Text text;
    [SerializeField] State state;

    void Update()
    {
        text.text = state.GetStoryText();
    }
}

Something like that should work. Assign the state to the state field. You don’t have to click on the Play button. It should display the text automatically. Don’t forget to assign the text game object to the “Text” field in your Inspector. And don’t forget to disable the Test script when you are done with testing.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms