Hello,
I am working on a message system (like Facebook or SMS, similar with the Mr. Robot Game) in my mobile game.
I found the "RememberCurrentDialogueEntry" script thanks to this forum and it is perfect for resuming a conversation. But now, I need to display every old messages of a conversation. In the API, I found functions like "MarkDialogueEntryUntouched" etc.. So I was wondering if DialogueSystem already has its own way to know what dialogueEntry was used, maybe with the right order and even a list of it ? I know that I can do it by making my own list, but if it already exist, it would be better to use it !
If it doesn't, what would be better :
Use the DialogueLua just like "RememberCurrentDialogueEntry" and add a list in it every ConversationLine like : DialogueLua.SetVariable("ListEntryIdOfXConv", myList);
Or use PlayerPrefs with my own XML Serialized class ?
Thank you !
Display old dialogueEntry
Re: Display old dialogueEntry
Hi,
Use the Conversation Log Dialogue UI on the Dialogue System Extras page. (direct download)
The example scene is formatted like a traditional fantasy RPG (e.g., Pillars of Eternity) but you can change out the graphics to make it look like a text message app.
Use the Conversation Log Dialogue UI on the Dialogue System Extras page. (direct download)
The example scene is formatted like a traditional fantasy RPG (e.g., Pillars of Eternity) but you can change out the graphics to make it look like a text message app.
Re: Display old dialogueEntry
Thank you for your reply.
I used this exemple and it was really helpful, but it do no save and display old messages. Once you leave the NPC, you do not have your previous conversation back when you go talk to him again. And this is what I need. I think i need to store it myself, but I just wanted to be sure.
I used this exemple and it was really helpful, but it do no save and display old messages. Once you leave the NPC, you do not have your previous conversation back when you go talk to him again. And this is what I need. I think i need to store it myself, but I just wanted to be sure.
Re: Display old dialogueEntry
Yes, for that part you will need to store it yourself. I recommend writing a script that has an OnConversationLine method.
For example, something like this script will record messages. It will also include them in saved game data.
RecordDialogueEntries.cs
When you go back to the same NPC, you will have to add the old messages back into the message log yourself. You do this in an OnConversationStart method.
For example, something like this script will record messages. It will also include them in saved game data.
RecordDialogueEntries.cs
Code: Select all
using UnityEngine;
using System;
using System.Collections.Generic;
using PixelCrushers.DialogueSystem;
public class RecordDialogueEntries : MonoBehaviour {
[Serializable]
public class Record {
public int conversationID;
public int entryID;
public Record(int conversationID, int entryID) {
this.conversationID = conversationID;
this.entryID = entryID;
}
}
private List<Record> records = new List<Record>();
void OnConversationLine(Subtitle subtitle) { // Called when showing a dialogue entry.
if (subtitle.dialogueEntry.id == 0) return; // Ignore START entry.
records.Add(new Record(subtitle.dialogueEntry.conversationID, subtitle.dialogueEntry.id));
}
void OnRecordPersistentData() { // Called when saving game.
var s = records.Count + ";";
foreach (var record in records) {
s += record.conversationID + ";" + record.entryID + ";";
}
DialogueLua.SetVariable("records", s);
}
void OnApplyPersistentData() { // Called when loading game.
var s = DialogueLua.GetVariable("records").AsString;
var ints = s.Split(';');
var numRecords = Tools.StringToInt(ints[0]);
records.Clear();
for (int i = 0; i < numRecords; i++)
{
var conversationID = Tools.StringToInt(ints[1 + i * 2]);
var entryID = Tools.StringToInt(ints[2 + i * 2]);
records.Add(new Record(conversationID, entryID));
}
}
}
Re: Display old dialogueEntry
Perfect ! Thank you very much