Page 1 of 1
Null Reference exception?
Posted: Mon May 02, 2016 3:38 pm
by bakershah
Hi,
I'm getting a null reference error for a bark I have set up. It works in one scene but when I copy and pasted the game objects for that bark into another scene it gave me this error:
NullReferenceException: Object reference not set to an instance of an object
PixelCrushers.DialogueSystem.BarkController+<Bark>c__Iterator5.MoveNext ()
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
PixelCrushers.DialogueSystem.DialogueSystemController:Bark(String, Transform, Transform, BarkHistory)
PixelCrushers.DialogueSystem.DialogueManager:Bark(String, Transform, Transform, BarkHistory)
no clue what the problem is...
Re: Null Reference exception?
Posted: Mon May 02, 2016 3:48 pm
by Tony Li
Hi,
Temporarily set the Dialogue Manager's Debug Level to Info. This should give you more information.
How are you triggering the bark? In your new scene, is a GameObject assigned as the barker?
Also, what version of the Dialogue System are you using? Version 1.6.2 is the current version on the Pixel Crushers customer download page (PM me your invoice number if you need access), and it should be on the Asset Store in a few days.
Re: Null Reference exception?
Posted: Tue May 03, 2016 11:48 am
by bakershah
Got these errors:
Dialogue System: Bark (speaker=Warrior NPC Bark (UnityEngine.Transform), listener=null): 'NPC Guard Thanks' has no START entry
UnityEngine.Debug:LogWarning(Object, Object)
also this:
Dialogue System: Conversation 'NPC Guard Thanks' not found in database.
UnityEngine.Debug:LogWarning(Object)
PixelCrushers.DialogueSystem.ConversationModel:.ctor(DialogueDatabase, String, Transform, Transform, Boolean, IsDialogueEntryValidDelegate, Int32)
PixelCrushers.DialogueSystem.<Bark>c__Iterator5:MoveNext()
Dialogue System: No dialogue database is assigned. (which is weird because It is assigned to the dialogue manager?)
UnityEngine.Debug:LogWarning(Object)
PixelCrushers.DialogueSystem.DialogueSystemController:InitializeDatabase()
PixelCrushers.DialogueSystem.DialogueSystemController:Awake()
UnityEngine.GameObject:AddComponent()
Re: Null Reference exception?
Posted: Tue May 03, 2016 11:48 am
by bakershah
To trigger the bark I have a disabled game object and when I trigger the bark I simply turn the object on and have the bark set to on start. The bark object is attached to the NPC itself.
Re: Null Reference exception?
Posted: Tue May 03, 2016 11:52 am
by bakershah
just realized none of my conversations in the scene are working... not sure what the problem is....
Re: Null Reference exception?
Posted: Tue May 03, 2016 1:07 pm
by Tony Li
Does your new scene have a Dialogue Manager? If so, is it set up the same way (e.g., same dialogue database assigned)?
Here are some things to keep in mind:
1. The Dialogue Manager works as a persistent singleton. This means (1) it allows only one instance of itself, and (2) it sticks around even when you change scenes.
2. If you're playing the new scene directly in the editor, the new scene should have a Dialogue Manager. This is the engine that the Conversation Triggers and Bark Triggers use. If it doesn't have a Dialogue Manager, conversations and barks can't run.
3. However, if you're playing from the old scene and change levels into the new scene, the old scene's Dialogue Manager will stick around, replacing the new scene's Dialogue Manager. This means that, technically, you don't need a Dialogue Manager in the new scene. However, it's useful to put a Dialogue Manager in the new scene anyway so you can playtest the new scene directly in the editor without coming from the old scene.
Re: Null Reference exception?
Posted: Wed Oct 05, 2016 1:16 am
by johnsonjeven
The
NullReferenceException is designed as a valid runtime condition that can be thrown and caught in normal program flow. It indicates that you are trying to access member fields, or function types, on an object reference that points to null. That means the reference to an Object which is not initialized.
Johnson