I am making a game that needs a timer. I am very noob at scripting and unity. my problem is the text I want to use to the timer. I cant drag the text to the inspector
public class Timer : MonoBehaviour
public Text timerText;
private float startTime;
// Start is called before the first frame update
startTime = Time.time;
// Update is called once per frame
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString();
string seconds = (t % 60).ToString();
timerText.text = minutes + ":" + seconds;
i dont know if that pictrues help.
Are you dragging the Text object from the Hierarchy?
You are trying to assign the reference to the default reference of your script asset itself. Here you can only setup references to other assets. You can not assign any references to concrete objects in a scene.
Anyways in most cases you don’t need / want to use the default references anyways. Attach your script to an actual object in your scene and assign the text instance to the variable on your script instance.
Default references are just an editor feature which allows you to specify certain default assets to be pre assigned whenever you attach that script to an object. This is a pure in-editor features. Default references have no effect at runtime at all.