PrintLastEntry.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class PrintLastEntry : MonoBehaviour
{
[ConversationPopup]
public string conversation;
void Update()
{
if (Input.GetKeyDown(KeyCode.F1))
{
// Get the last entry for conversation:
string history = DialogueLua.GetVariable("DialogueEntryRecords_" + conversation).asString;
string[] fields = history.Split(';');
var numRecords = (fields.Length > 0) ? Tools.StringToInt(fields[0]) : 0;
Debug.Log("Conversation has " + fields[0] + " records.");
if (numRecords > 0)
{
int conversationID = Tools.StringToInt(fields[fields.Length - 3]);
int entryID = Tools.StringToInt(fields[fields.Length - 2]);
Debug.Log("Last record is [" + conversationID + ":" + entryID + "] -- " + history);
DialogueEntry entry = DialogueManager.masterDatabase.GetDialogueEntry(conversationID, entryID);
if (entry != null)
{
Debug.Log("Last entry is: " + entry.DialogueText);
}
}
}
}
}
To use it when first starting the game (before you've gone to the gameplay scene), tick the Menu System > Auto Save Load component's Load On Start checkbox. This will load the database when game starts.