Tony Li wrote: ↑Wed Apr 15, 2020 8:26 am
Good catch! Make a subclass of DialogueSystemSaver, and use it in place of the original DialogueSystemSaver. In ApplyData(), call ArticyTools.InitializeLuaSubtables():
DialogueSystemSaverWithArticy.cs
Code: Select all
namespace PixelCrushers.DialogueSystem
{
public class DialogueSystemSaverWithArticy : DialogueSystemSaver
{
public override void ApplyData(string data)
{
base.ApplyData(data);
PixelCrushers.DialogueSystem.Articy.ArticyTools.InitializeLuaSubtables();
}
}
}
Hi Tony,
I was experiencing the same issue, but with the PersistentDataManager instead of the complete Save System. The situation is the same: I start from a game launcher (main menu), then I load a saved game.
Based on your solution, I tried to call
InitializeLuaSubtables() just after the line
PersistentDataManager.ApplySaveData. Problem solved, now I can get the lua subtable.
But...
When I iterate over the stripTable, each element now has only one Key/Value pair in its table (so there is no Technical Name, which is what I'm looking for here)!
Code: Select all
public static string[] GetStripElementsIDs(LuaTableWrapper stripTable)
{
string[] elementsIDs = new string[stripTable.count];
int i = 0;
foreach (LuaTableWrapper element in stripTable.Values)
{
elementsIDs[i] = element[DialogueLua.StringToTableIndex(MyToolbox.Lua.ArticyFields.techName)].ToString(); // <-- Null Reference Exception
i++;
}
return elementsIDs;
}
The only existing field is the one explicitly saved with "PersistentDataManager.GetCustomSaveData" (I don't want to save the other fields).
When I don't load the lua environment (that is, when I start directly from the Unity editor), the same LuaTableWrapper element shows almost 20 key/value pairs, and the field I'm looking for exists, and everything works fine.
So, to summarize:
case A (no loading)
-> InitializeLuaSubtables
-> iterate over the strip -> found 3 elements with almost their 20 fields
case B (starting from main menu, loading)
-> InitializeLuaSubtables
-> load lua environment
-> InitializeLuaSubtables
-> iterate over the strip -> found 3 elements with only 1 field, the one previously saved withPersistentDataManager.GetCustomSaveData. The other fields seem to be gone.
Any idea of what's happening?