Page 1 of 1

Null reference exception on DLL when responses appear

Posted: Wed Mar 28, 2018 4:26 am
by patxiku
Hi!

I'm having a Null Reference Exception each time a response panel is shown, the error is the following:

Code: Select all

Dialogue System: In ShowResponses(): Object reference not set to an instance of an object
UnityEngine.Debug:LogError(Object)
PixelCrushers.DialogueSystem.AbstractDialogueUI:ShowResponses(Subtitle, Response[], Single)
PixelCrushers.DialogueSystem.UnityUIDialogueUI:ShowResponses(Subtitle, Response[], Single) (at Assets/ThirdParty/Dialogue System/Scripts/Supplemental/UI/Dialogue UI/UnityUIDialogueUI.cs:297)
ScarecrowStudio.Modules.Dialogue.UI.Components.Overrides.ScarecrowDialogueUI:ShowResponses(Subtitle, Response[], Single) (at Assets/Scripts/Game/Modules/Dialogue/Core/UI/Components/Dialogue System Overrides/ScarecrowDialogueUI.cs:56)
PixelCrushers.DialogueSystem.ConversationView:StartResponses(Subtitle, Response[])
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle(Object, EventArgs)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle()
PixelCrushers.DialogueSystem.ConversationView:OnFinishedSubtitle()
PixelCrushers.DialogueSystem.Sequencer:FinishSequence()
PixelCrushers.DialogueSystem.Sequencer:Update()
My custom class ScarecrowDialogueUI inherits from UnityUIDialogueUI and it's ShowResponses method is the following one:

Code: Select all

public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout) {
	GlobalProperties.Dialogue.SetEntryType(DialogueProperties.EntryType.Response); 
        for(int i = 0; i < responses.Length; i++) {
        	responses[i].formattedText.text = ParseCommas(responses[i]); //I parse a code into commas
        }
        ase.ShowResponses(subtitle, responses, timeout);
        OverrideStyle(false, null); //styling stuff, doesn't change anything about the responses nor subtitles
}
Also, the second time I call the same dialogue, for some reason Dialogue System calls ShowResponses twice instead of once as in the first execution.

What can the problem be?

Thanks in advance,

Julen

Re: Null reference exception on DLL when responses appear

Posted: Wed Mar 28, 2018 9:59 am
by Tony Li
Hi,

The base class, AbstractDialogueUI, catches exceptions, which is good because it prevents the game from crashing due to misconfigurations, but bad because it can make it hard to track down errors in custom subclasses.

Try changing your override ShowResponses to only call:

base.ShowResponses(subtitle, responses, timeout);

If it doesn't work, check that the UI elements are all assigned correctly.

If it works, then add the other pieces of code one at a time.