Hi,
For persistence, you may be able to use the save system's
Spawned Object Manager.
If you're spawning an NPC that has a Dialogue System Trigger, and you have an NPCData object, you can set its Dialogue System Trigger's conversation like this:
Code: Select all
// Assume npcData is a reference to the NPCData object and spawnedNPC is a reference to the NPC.
var dialogueSystemTrigger = spawnedNPC.GetComponent<DialogueSystemTrigger>();
dialogueSystemTrigger.conversation = npcData.dialogueName;
Side note: You can turn dialogueName into a dropdown menu using the
[ConversationPopup] attribute:
Code: Select all
public class NPCData
{
public string characterName; //same as the scriptableObject with prefab reference
[ConversationPopup(true)] public string dialogueName; //get by the NPC and set on his dialogue trigger (on use) on the spawn of the npc
public Vector3 position; //position to spawn
}
I may be misunderstanding where the NPCData object comes from, but hopefully the info above is useful anyway. Now that I re-read your reply, it looks like NPCData may be constructed from this command:
LoadNPC("NPCName", "SceneName","Conversation to start", "Vector 3 position")
If the NPC info is already in the scene, maybe you can use a single reference to that info. Let's say you have an NPC named Adam. Would Adam always appear in the same position in the same scene (e.g., middle of the museum scene) and play the same conversation? In this case, the designer is just triggering an event that causes Adam to appear in this "hard-coded" configuration. If so, it's easier to set up.
On the other hand, if the designer can make Adam appear at any place in any scene and play any conversation, it's still possible, but I don't have any good suggestions yet on how to handle it all "point-and-click" rather than having to type some of that info. Are the designers using the Dialogue Editor window to create content, or are they using an external editor such as Arcweave or articy:draft?