While trying to reproduce it in the example you provided—so effectively a vacuum—I realized the issue is not the UI or Dialogue Manager settings. I copied over the prefabs we use in our project (just had to fix missing references to sprites and UI materials, in our dialogue UI, and add Text Animator and TMP integration)
The answer to your previous questions is yes, and I double-checked the actor assignments, which ended up correct. The custom class works as expected in the example project, so I assumed the source of the problem couldn't be with the conversation or UI, nor the Dialogue Manager, but somewhere else.
I have this method in a different class, called GameManager:
Code: Select all
public void UpdateGenders(Gender playerGenderChoice)
{
PlayerGender = playerGenderChoice;
DialogueLua.SetVariable("PlayerName", IsPlayerMale ? "MMC" : "FMC");
DialogueLua.SetVariable("PlayerSheHe", IsPlayerMale ? "he" : "she");
DialogueLua.SetVariable("PlayerHerHim", IsPlayerMale ? "him" : "her");
DialogueLua.SetVariable("SiblingName", IsPlayerMale ? "Fibling" : "Mibling");
DialogueLua.SetVariable("SiblingSheHe", IsPlayerMale ? "she" : "he");
DialogueLua.SetVariable("SiblingHerHim", IsPlayerMale ? "her" : "him");
DialogueLua.SetVariable("ThiefName", IsPlayerMale ? "Fanny Shultz" : "Danny Shultz");
DialogueLua.SetVariable("ThiefSheHe", IsPlayerMale ? "she" : "he");
DialogueLua.SetVariable("ThiefHerHim", IsPlayerMale ? "her" : "him");
switch (playerGenderChoice)
{
case Gender.Female:
DialogueLua.SetActorField("Player", DialogueSystemFields.DisplayName, "FMC");
DialogueLua.SetActorField("Sibling", DialogueSystemFields.CurrentPortrait, "Portrait_Player_Male");
DialogueLua.SetActorField("Sibling", DialogueSystemFields.DisplayName, "Mibling");
DialogueLua.SetActorField("Thief", DialogueSystemFields.CurrentPortrait, "Portrait_Thief_Male");
DialogueLua.SetActorField("Thief", DialogueSystemFields.DisplayName, "Thief Boy");
break;
case Gender.Male:
DialogueLua.SetActorField("Player", DialogueSystemFields.DisplayName, "MMC");
DialogueLua.SetActorField("Sibling", DialogueSystemFields.CurrentPortrait, "Portrait_Player_Female");
DialogueLua.SetActorField("Sibling", DialogueSystemFields.DisplayName, "Fibling");
DialogueLua.SetActorField("Thief", DialogueSystemFields.CurrentPortrait, "Portrait_Thief_Female");
DialogueLua.SetActorField("Thief", DialogueSystemFields.DisplayName, "Thief Girl");
break;
}
It only runs on Start() of the GameManager game object, and when I choose the player's gender in a different scene, always before conversations. While testing previously, it was never called more than once after its Start.
If I comment out the entire switch (but keep the SetVariables above), our main problem seems to go away. What gives? The player's portrait isn't even changed with a SetActorField line. As soon as I uncomment the switch, the issue comes back. After this "fix" (hopefully), I haven't been able to reproduce the
"retain their last displayed portrait from a previous conversation in a new one" bug either, but I can't rule it out yet.
Those fields exist in the dialogue database with an initial value, so they are not created at runtime like the OnConversationStart variables we use for switching portraits with sequences. I know the database is read-only, and the lua environment serves as a "virtual machine" during runtime. Still, I don't understand how this switch messes up the Player actor's portrait UNTIL it starts playing a subtitle without even touching a relevant field, and the OnConversationStart method runs after it. The Sibling and Thief conversants were more or less correct (might be the cause for the "retaining problem", so deleting this switch may just end up fixing it).
I'm confused, but it seems to work! Thank you very much for your help! If you don't mind, I would appreciate insight on this so I can avoid running into a similar issue down the line.