Search Unity

Strange error message in console

Discussion in 'Getting Started' started by MarkSteere, Mar 5, 2023.

  1. MarkSteere

    MarkSteere

    Joined:
    Dec 31, 2022
    Posts:
    54
    UnassignedReferenceException: The variable Setup_Tile of Checker has not been assigned.
    You probably need to assign the Setup_Tile variable of the Checker script in the inspector.
    Checker.Start () (at Assets/Scripts/Checker.cs:10)

    It's strange because I *did* assign the Setup_Tile variable of the Checker script in the inspector, and the program is working properly, placing the checkers on their respective setup tiles.
     
  2. MarkSteere

    MarkSteere

    Joined:
    Dec 31, 2022
    Posts:
    54
    Code (CSharp):
    1. public class Checker : MonoBehaviour
    2. {
    3.     // Start is called before the first frame update
    4.     void Start()
    5.     {
    6.         this.transform.position = Setup_Tile.transform.position;
    7.     }
    8.  
    9.     public GameObject Setup_Tile;
    10.  
    11.     // Update is called once per frame
    12.     void Update()
    13.     {
    14.        
    15.     }
    16.  
    17.     void OnMouseDown()
    18.     {
    19.         Debug.Log(this.transform.name + ", " + this.transform.parent.name);
    20.     }
    21. }
    22.  
     
  3. MarkSteere

    MarkSteere

    Joined:
    Dec 31, 2022
    Posts:
    54
    Found it. The script was being applied to both the checker container and the checker within it.

    Thanks anyway.