[Solved] NullPointer bug

I’ve followed this lecture exactly and even checked with the lecture changes on the repository. For some reason whenever I try to close the dialogue I get a NullPointer exception on this line in QuestListUI

QuestItemUI uiInstance = Instantiate(questPrefab, transform);

The error claims that questPrefab is null and indeed when I attach debuger the prefab is null whenever I try to close the dialogue. However, when I try to open the quest log, then start is called again, therefore redraw is called again and the prefab is fine, no errors. Since this bug does not really affect gameplay, but only UI I can get around it with a null check for the prefab and everything works fine. However it would be nice to know why this happens (something to do with the inactivity of quest ui until I call it on screen?)

By the way if my quest ui is open during the dialogue it does work as expected.

Where do you set questPrefab? If it’s null in some cases it may be because you have another ‘rogue’ component somewhere that has not been set.

Bixarrio that was exactly the problem. I have added somehow by mistake a QuestListUI to QuestUI and ofc haven’t setup the prefab, as the component was not expected there. Thanks a lot!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms