This is a super basic question, i'm sure, but I can't find an answer. So I notice that whenever another script is referenced at the top of a class you have to drag it into the Unity inspector slot as well or else it will return a null reference exception. For Example:
public class ExampleClass : MonoBehaviour
{
public ScriptExample1 scriptexample1;
public void Method()
{
scriptexample1.score++;
}
}
However, if the script is referenced as a method parameter you do not have to drag it into the inspector slot. For Example:
public class ExampleClass : MonoBehaviour
{
public void Method(ScriptExample2 scriptexample2)
{
scriptexample2.score++;
}
}
Can someone please explain to me why ScriptExample1 needs the script to be dragged into the inspector slot and ScriptExample2 doesn't?
Thank you,