Question: A programmer is trying to create some simple code to print the players name: public class PrinterPlayerName : MonoBehavior { [ SerializedField ] GameObject player;

A programmer is trying to create some simple code to print the players name:
public class PrinterPlayerName : MonoBehavior
{
[SerializedField] GameObject player;
private void Start ()
{
Debug.Log(player.name);
}
void printPlayerName(GameObject player){
Debug.Log(player.name);
}
}
However the following error is being printed to the Console: "UnassignedReferenveException: The variable player of PrintPlayerName has not been assigned." Why is this happening?
A.) The GameObject does not have a name field inside.
B.) The wrong GameObject was assigned in the Inspector
C.) The player variable should be public to be able to assign it in the Inspector
D.) The player GameObject was not assigned in the Inspector

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!