Need help with unity

i am using udemy and i was stuck on the textComponent
here ya go

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AdventurGame : MonoBehaviour
{
   [SerializeField] Text textComponent;
   [SerializeField] State startingState;

    State state;

    // Start is called before the first frame update
    void Start()
    {
        state = startingState;
        textComponent.text = state.GetStateStory();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

Hi,

NullReferenceException means that a reference (“link”) to an instance is missing. If you exposed a field in the Inspector, make sure that it’s not empty.

it dosent let me put starting state in my aventure game script

whenever i try to it takes it out i play mode

Do not attach anything in Play Mode. You have to stop your game, then attach objects to your AdventureGame component, then run your game.

nice thanks

Is the issue fixed?


See also:

yep

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

Privacy & Terms