Hi Tony!
I've been experiencing a random (as in, doesn't happen every time) game-breaking issue when I restart the game. This happens mostly when I restart the game from the "end of the game", rather than from the pause menu.
Now, the game begins with a few-seconds-long cutscene and then a Conversation and this is the MissingReferenceException error I'm getting, sometimes, when that conversation starts:
Code: Select all
MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
PixelCrushers.DialogueSystem.SequencerTools.FindSpecifier (System.String specifier, System.Boolean onlyActiveInScene) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/SequencerTools.cs:165)
PixelCrushers.DialogueSystem.SequencerTools.GetSubject (System.String specifier, UnityEngine.Transform speaker, UnityEngine.Transform listener, UnityEngine.Transform defaultSubject) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/SequencerTools.cs:113)
PixelCrushers.DialogueSystem.Sequencer.HandleSetActiveInternally (System.String commandName, System.String[] args) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:1948)
PixelCrushers.DialogueSystem.Sequencer.HandleCommandInternally (System.String commandName, System.String[] args, System.Single& duration) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:1168)
PixelCrushers.DialogueSystem.Sequencer.ActivateCommand (System.String commandName, System.String endMessage, UnityEngine.Transform speaker, UnityEngine.Transform listener, System.String[] args) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:811)
PixelCrushers.DialogueSystem.Sequencer.PlayCommand (PixelCrushers.DialogueSystem.SequencerCommands.QueuedSequencerCommand commandRecord, System.String commandName, System.Boolean required, System.Single time, System.String message, System.String endMessage, System.String[] args) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:772)
PixelCrushers.DialogueSystem.Sequencer.PlayCommand (PixelCrushers.DialogueSystem.SequencerCommands.QueuedSequencerCommand commandRecord) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:741)
PixelCrushers.DialogueSystem.Sequencer.PlaySequence (System.String sequence) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:675)
PixelCrushers.DialogueSystem.Sequencer.PlaySequence (System.String sequence, System.Boolean informParticipants, System.Boolean destroyWhenDone) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs:685)
PixelCrushers.DialogueSystem.ConversationView.StartSubtitle (PixelCrushers.DialogueSystem.Subtitle subtitle, System.Boolean isPCResponseMenuNext, System.Boolean isPCAutoResponseNext) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs:191)
PixelCrushers.DialogueSystem.ConversationController.GotoState (PixelCrushers.DialogueSystem.ConversationState state) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:212)
PixelCrushers.DialogueSystem.ConversationController.Initialize (PixelCrushers.DialogueSystem.ConversationModel model, PixelCrushers.DialogueSystem.ConversationView view, System.Boolean alwaysForceResponseMenu, PixelCrushers.DialogueSystem.ConversationController+EndConversationDelegate endConversationHandler) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Controller/ConversationController.cs:155)
PixelCrushers.DialogueSystem.DialogueSystemController.StartConversation (System.String title, UnityEngine.Transform actor, UnityEngine.Transform conversant, System.Int32 initialDialogueEntryID) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:950)
PixelCrushers.DialogueSystem.DialogueSystemController.StartConversation (System.String title, UnityEngine.Transform actor, UnityEngine.Transform conversant) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueSystemController.cs:997)
PixelCrushers.DialogueSystem.DialogueManager.StartConversation (System.String title, UnityEngine.Transform actor, UnityEngine.Transform conversant) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Manager/DialogueManager.cs:475)
AC.ActionDialogueSystemConversation.Run () (at Assets/AdventureCreator/Scripts/Actions/ActionDialogueSystemConversation.cs:96)
AC.ActionList+<RunAction>d__41.MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:425)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <ca42919df2b74e53b11002749c8755af>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:375)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:567)
AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:526)
AC.<RunAction>d__41:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:490)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:375)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:567)
AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:526)
AC.<RunAction>d__41:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:490)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:375)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:567)
AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:526)
AC.<RunAction>d__41:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:490)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:375)
AC.ActionList:BeginActionList(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:342)
AC.ActionList:Interact(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:243)
AC.ActionRunActionList:Run() (at Assets/AdventureCreator/Scripts/Actions/ActionRunActionList.cs:169)
AC.<RunAction>d__41:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:425)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:375)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:557)
AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:526)
AC.<RunAction>d__41:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:490)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Now, I'm not sure whether it is actually referring to these two Transforms, but, needless to say, they're in the scene.
Now, on to provide as much context as possible!
I restart the game, either through the pause menu or at the "end of the game", using custom code (that is, not by using AdventureCreator's "Engine: End Game -> Restart Game" Action) based on what I've found here, on the AdventureCreator forums.
I basically "add" to the code provided there to cater for my own needs, that includes NOT resetting the Player, as it has Addressables-loaded Here's the full method I'm using:
Code: Select all
DialogueManager.StopAllConversations();
DialogueManager.ResetDatabase();
// Stops my own sound implementation
GameSFXManager.instance.Stop();
AC.KickStarter.music.StopAll(0f);
// Clears a list of strings that stores the IDs of quests and objectives
QuestLogTracker.instance.Clear();
// Marks all the spots on the game map as "unvisited"
Navigator.instance.m_Map.Nodes.ForEach(x => x.WasVisited = false);
// Resets the status of all the "tutorial" variables
InfoPointsTracker.instance.InfoPoints.ForEach(x => x.WasChecked = false);
AC.KickStarter.runtimeInventory.SetNull();
AC.KickStarter.runtimeInventory.RemoveRecipes();
if (AC.KickStarter.settingsManager.blackOutWhenInitialising)
{
AC.KickStarter.mainCamera.ForceOverlayForFrames(6);
}
// Resets the "quest tracking system"
ObjectiveTracker.instance.ResetIt();
AC.KickStarter.saveSystem.ClearAllData();
AC.KickStarter.levelStorage.ClearAllLevelData();
AC.KickStarter.stateHandler.Initialise(false);
AC.PlayerMenus.GetMenuWithName("Pause").TurnOff();
AC.PlayerMenus.GetMenuWithName("TopBar").TurnOff();
AC.KickStarter.eventManager.Call_OnRestartGame();
AC.KickStarter.stateHandler.CanGlobalOnStart();
AC.KickStarter.sceneChanger.ChangeScene("StartScene", false, true);
// Resets the main character outfit to the default one
OutfitManager om = AC.KickStarter.player.GetComponent<OutfitManager>();
om.WearOutfit(om.GetOutfit("default"));
// Sets an internal state machine
GameStateManager.instance.SetState(GameStates.START);
I'm straight-away observing the Lua variables imported from Articy and, when I reach a certain value while playing, I trigger either a new quest or a new objective or whatever special event needs to happen when a certain moment in the game is reached (e.g. tracking when a "tutorial popup" should appear).
That said, what I try to do while resetting (or loading) is to try and make sure I'm not re-observing the same variables and that I clear everything that needs to be cleared so to actually "reset" everything to its default state.
I'm not sure this is all necessary context, but I hope it is helpful.
In the meantime - and as always - thanks a lot!