Hi,
Yes, but it requires a little bit of scripting or PlayMaker or equivalent.
First, you'll want to keep track of the current dialogue entry node. Add a script like this to the Dialogue Manager:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class RememberCurrentDialogueEntry : MonoBehaviour {
public void OnConversationStart(Transform actor) {
var actorName = (DialogueManager.CurrentActor != null) ? DialogueManager.CurrentActor.name : string.Empty;
var conversantName = (DialogueManager.CurrentConversant != null) ? DialogueManager.CurrentConversant.name : string.Empty;
DialogueLua.SetVariable("CurrentConversationActor", actorName);
DialogueLua.SetVariable("CurrentConversationConversant", conversantName);
}
public void OnConversationLine(Subtitle subtitle) {
DialogueLua.SetVariable("CurrentConversationID", subtitle.dialogueEntry.conversationID);
DialogueLua.SetVariable("CurrentEntryID", subtitle.dialogueEntry.id);
}
public void OnConversationEnd(Transform actor) {
DialogueLua.SetVariable("CurrentConversationID", -1);
}
public void OnApplyPersistentData() {
var conversationID = DialogueLua.GetVariable("CurrentConversationID").AsInt;
var entryID = DialogueLua.GetVariable("CurrentEntryID").AsInt;
if (conversationID >= 0 && entryID > 0) {
var conversation = DialogueManager.MasterDatabase.GetConversation(conversationID);
var actorName = DialogueLua.GetVariable("CurrentConversationActor").AsString;
var conversantName = DialogueLua.GetVariable("CurrentConversationConversant").AsString;
var actor = GameObject.Find(actorName);
var conversant = GameObject.Find(conversantName);
var actorTransform = (actor != null) ? actor.transform : null;
var conversantTransform = (conversant != null) ? conversant.transform : null;
DialogueManager.StopConversation();
DialogueManager.StartConversation(conversation.Title, actorTransform, conversantTransform, entryID);
}
}
}
This script does four things:
1. At the start of the conversation, it records the actor and conversant GameObject names.
2. Every line, it records the conversation and dialogue entry node ID.
3. At the end of the conversation, it sets CurrentConversationID to -1 to signify that no conversation is active.
4. When a game is loaded, it checks the recorded information. If a conversation was active, it starts that conversation at the recorded dialogue entry node.
To save, run this code (or the PlayMaker etc. equivalent):
Code: Select all
string saveData = PersistentDataManager.GetSaveData();
then save that string somewhere. For example:
Code: Select all
PlayerPrefs.SetString("savedgame", saveData);