Script on button game object

I’ve been attempting to put a script on a button for a while and it is resisting my efforts. I’m sure it’s something simple that I’m doing that’s causing the problem. Any help would be appreciated.

public class HelpText : MonoBehaviour
    [SerializeField] string helpText;

    [SerializeField] TextMeshProUGUI contentText;

    [SerializeField] GameObject helpTextScrollView;

    [SerializeField] bool isVisible = true;

    HelpText[] openHelpTexts;

    RectTransform rectTransform;

    private void Start()
        rectTransform = helpTextScrollView.GetComponent<RectTransform>();
        contentText.text = helpText;

The issue I run into is anything I assign in the editor is null on reaching the Start method. The object I’m putting the script on is a button.

I think I’ve been focused on the problem for so long that I can’t see something obvious. Again, thanks for any insight.

Turns out the issue was related to having duplicate copies of the script on the object. Just didn’t scroll to see the other copy. Coding while tired != good.

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

Privacy & Terms