I’m trying to reference the grid object which contains a script that has my inventorygrid class. I’m referencing from another script attached to the ui camera.
Its assigned like this:
I’m just trying to reference it like this:
public class InventoryController : MonoBehaviour
{
[SerializeField] private InventoryGrid selectedInventoryGrid;
private void Update()
{
if (selectedInventoryGrid = null)
{
Debug.Log("InventoryGrid IS null.");
return;
}
selectedInventoryGrid.GetTileGridPosition(Input.mousePosition);
}
}
However, when trying to run the referenced class and method, I get “Object reference not set to an instance of an object.”. I’ve noticed that the “Selected Inventory Grid” that I’ve assigned just unassigns itself when I run the game.