I need help figuring out the problem here:
public class Colony : MonoBehaviour
{
//...
public Dictionary<ResourceType, float> ResourceAmounts = new Dictionary<ResourceType, float>();
void Awake()
{
Debug.Log("New Colony starts up...");
_transform = transform;
InitializeColony();
//...
}
// Update is called once per frame
void Start()
{
MainGUIPanel.Instance.GiveColony(this);
}
private void InitializeColony()
{
ResourceAmounts[ResourceType.Food] = 100f;
ResourceAmounts[ResourceType.Water] = 100f;
ResourceAmounts[ResourceType.Eggs] = 3f;
Memory = new Memory(this);
}
}
public class MainGUIPanel : MonoBehaviour
{
public static MainGUIPanel Instance;
[SerializeField] private Colony _colony;
//...
void Start()
{
Instance = this;
// ...
}
public void GiveColony(Colony colony)
{
_colony = colony;
}
public void Update()
{
UpdateColonyStats();
// ...
}
private void UpdateColonyStats()
{
Colony colony = _colony;
Dictionary<ResourceType, float> resourceAmounts = colony.ResourceAmounts;
}
That last line is the one giving me a NullReferenceException and I can't figure out why.