Creating a Farming RPG (like Harvest Moon) in Unity — Part 12: Sleeping and SavingThis article is a part of the series: Creating a Farming RPG (like Harvest Moon) in Unity To view this content, you must be a member of Terresquall's Patreon at $5 or more Unlock with PatreonAlready a qualifying Patreon member? Refresh to access this content.
There are 2 comments:
After completing this tutorial when I launch I get a unity pause with the issue –
*NullReferenceException: Object reference not set to an instance of an object*
In reference to this line – List landData = LandManager.farmData.Item1;
Then when I un-pause unity it runs fine.
Hi Corey, for Unity pausing on error, it’s because you enabled Error Pause in the Unity Editor: https://answers.unity.com/questions/737305/unity-pausing-when-runtime-error-occurs.html
As for the NullReferenceException, whenever you get this, what you want to look at are at areas where you have a chain of full-stops (.), because what it is saying is that one of the objects you are referring to in the chain is null.
In your case, it can mean that LandManager.farmData is null, or LandManager.farmData.Item1 is null. You can check if either item is null by doing a print before the line:
Once you find which is the null item, ensure that it is filled and the error should go away.