Yes I did, but I replayed again
. I'll put here the message:
OK, everything works fine and the Invector inventory saves and loads fine...
But related to saving and loading the procedural states.....
--------------------------------------------------------------------------------------------
I get this error when anytime I have saved any procedural quest with this code You gave me one month ago to save automatically the quest states: (At the end of the message)
And once the scene restarts and loads, i get the following error: and whats worst, I lose all the quest on my journal (I guess is because it loads empty or wrong because this error)
ArgumentNullException: Value cannot be null.
Parameter name: key
System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].ContainsKey (TKey key) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
PixelCrushers.QuestMachine.QuestMachine.GetImage (System.String imageName) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest Machine/QuestMachine.cs:503)
PixelCrushers.QuestMachine.IconQuestContent.OnAfterProxyDeserialization () (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest Subasset/Quest Content/IconQuestContent.cs:82)
PixelCrushers.QuestMachine.QuestContentProxy.CreateList (PixelCrushers.QuestMachine.QuestContentProxy[] contentListProxy) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest Serialization/QuestProxy.cs:518)
PixelCrushers.QuestMachine.QuestProxy.CopyTo (PixelCrushers.QuestMachine.Quest quest) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest Serialization/QuestProxy.cs:114)
PixelCrushers.QuestMachine.QuestListContainer.ApplyData (System.String data) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:332)
PixelCrushers.QuestMachine.QuestJournal.ApplyData (System.String data) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestJournal.cs:128)
PixelCrushers.SaveSystem.ApplySavedGameData (PixelCrushers.SavedGameData savedGameData) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:497)
UnityEngine.Debug:LogException(Exception)
PixelCrushers.SaveSystem:ApplySavedGameData(SavedGameData) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:502)
PixelCrushers.<LoadSceneCoroutine>c__Iterator4:MoveNext() (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:599)
--------------------------------------------- code -------------------
using UnityEngine;
using PixelCrushers;
using PixelCrushers.QuestMachine;
public class QuestNodeControllerSaver : MonoBehaviour, PixelCrushers.IMessageHandler
{
public int Slot = 0;
void OnEnable()
{ // Let me know when quest states change.
MessageSystem.AddListener(this, QuestMachineMessages.QuestStateChangedMessage, string.Empty);
}
void OnDisable()
{ // Unregister when disabling script.
MessageSystem.RemoveListener(this);
}
public void OnMessage(MessageArgs messageArgs)
{
//Recoge Cambio en el estado de una Quest
//QuestState state = (QuestState)messageArgs.values[1];
//Recoge Cambio en el estado del nodo de una Quest
QuestNodeState state = (QuestNodeState)messageArgs.values[1];
StringField nodeID = messageArgs.values[0] as StringField;
if (nodeID == null)
{
return; // Is main quest.
}
//Comprueba si es activa la quest
//if (state == QuestState.Active)
//Comprueba si es activa el nodo de la quest
if (state == QuestNodeState.Active)
{ // Quest Node became active. Save game.
//Guardamos en el slot 0, que lo reservamos para guardar los estados de cambios de Nodos / quests
int SlotPrincipal = 0;
PlayerPrefs.SetString("slot_saveName_" + SlotPrincipal, System.DateTime.Now.ToString());
PlayerPrefs.SetInt("slot_" + SlotPrincipal, SlotPrincipal);
PlayerPrefs.SetString("slot_sceneName_" + SlotPrincipal, "CrazyPiratesOpenWorld");
//Save
SaveSystem.SaveToSlot(SlotPrincipal);
//Y además Grabación de BackUp:
Slot +=1; // Use 5 slots, wrapping around back to 1.
if (Slot > 5) Slot = 1;
//Pone la fecha
PlayerPrefs.SetString("slot_saveName_" + Slot, System.DateTime.Now.ToString());
//POne el numero de slot
PlayerPrefs.SetInt("slot_" + Slot, Slot);
//Nombre de escena
PlayerPrefs.SetString("slot_sceneName_" + Slot, "CrazyPiratesOpenWorld");
//Save
SaveSystem.SaveToSlot(Slot);
Debug.Log("Save Quest Node");
if (Invector.vCharacterController.vHUDController.instance)
Invector.vCharacterController.vHUDController.instance.ShowText("Save Quest Node");
}
}
}
UPDATE:
After some research.....
- The error fires always when I REload the scene, so I think is not the origin of the issue.
- We may need to filter the nodeID not to save when is a Procedural Quest, as when I load the game its empty, but I don't know how to do it. Can you help me to filter it?
Should be on the above code somehow.