Text on UI Button Not Updating

Hi there,

I have a button that’s suppose to toggle between a map editor and the game state. The button correctly toggles the game state, but it does not correctly update the text on the button. Yet if I debug the button text…it shows that it should have changed. I have absolutely no idea what to do here. Code:

    [SerializeField] Button mapEditorButton = default;
    string mapEditorButtonLabel;
    private void Start()
        mapEditorButtonLabel = mapEditorButton.GetComponentInChildren<Text>().text;

   public void ToggleMapEditor() {
        bool mapEditorActive = Game.Instance.GetInputState().GetType() == typeof(InputEditorDefault);

        if (mapEditorActive) {
            mapEditorButtonLabel = "Open Map Editor";
        else {
            mapEditorButtonLabel = "Return to Game";


The button eternally shows the placeholder text I have for it, despite the following output:


I am using 2019.2.6f1 personal :slight_smile:

Figured it out. Apparently you cannot cache properties as variables, so having mapEditorButtonLabel be a string and assigning Button.Text.text to it is invalid. Changed it to Text = mapEditorButtonLabel, and assigned mapEditorButton.GetComponentInChildren<Text>() to it, and then did the assignment through mapEditorButtonLabel.text = foo