It's great that you asked those questions early. They're all UI-related, so it will be good to get it straightened out before making changes to your UI. No need to start a separate thread.
UKMasters wrote: ↑Sun Aug 16, 2020 10:53 amI'm presuming that you append the entries to a separate "text object". If so, is there a way to preserve or add formatting? (e.g. different colours for NPC and player). Based on previous experience you might have already thought of this!
Formatting uses embedded rich text codes, so they're already included and preserved.
UKMasters wrote: ↑Sun Aug 16, 2020 10:53 amDoes the single text log persist throughout the entire game? (i.e. across multiple conversations?). I would like it to persist, so that the player can look back at the choices they've made; because earlier choices will impact what happens later on.
This isn't built in. But if you don't mind a small dive into coding, you can add it. Here's an example. It uses two of the Dialogue System's
special script methods: OnConversationStart and OnConversationLine.
Code: Select all
using PixelCrushers.DialogueSystem;
using UnityEngine;
public class RecordAllText : MonoBehaviour // ADD ME TO THE DIALOGUE MANAGER.
{
public string allText; // This string accumulates all dialogue shown in the game.
private StandardUISubtitlePanel GetSubtitlePanel()
{
var ui = DialogueManager.dialogueUI as StandardDialogueUI;
return ui.conversationUIElements.defaultNPCSubtitlePanel;
}
void OnConversationStart(Transform actor)
{
// Add the conversation title to allText:
allText += DialogueManager.lastConversationStarted + "\n";
// Show the accumulated allText in the subtitle panel:
GetSubtitlePanel().accumulatedText = allText;
}
void OnConversationLine(Subtitle subtitle)
{
// Add each non-blank line to allText:
if (!string.IsNullOrEmpty(subtitle.formattedText.text))
{
allText += subtitle.formattedText.text + "\n";
}
}
// Use this method to add extra text to the conversation log:
public void AddSpecialText(string text)
{
allText += text;
GetSubtitlePanel().subtitleText.text += text;
GetSubtitlePanel().accumulatedText += text;
}
}
For a more detailed example of these special script messages, examine the script ConversationLogger.cs.
You may also want to tick the Dialogue Manager's Subtitle Settings > Show PC Subtitles During Line and UNtick Skip PC Subtitle After Response Menu.
UKMasters wrote: ↑Sun Aug 16, 2020 10:53 amIs it possible to add in the title of the Conversation into the Text Log? So that when a separate Scenario (conversation) in my game is started, it will add the Title of the Scenario
I included that in the example script above.
UKMasters wrote: ↑Sun Aug 16, 2020 10:53 amIs it possible to add other things into the log (e.g. via scripting or things you've already included in the settings)? For example, when a player's skill level increases, or when they complete a quest, it would be great to include this message in the log (I don't want to write everything to the log, just key things).
Yes. In the example script above, I included an AddSpecialText() method. If you want to add the special text from a dialogue entry's Script field, you can
register this method with Lua. (The Tutorials section has a video tutorial on this.)
UKMasters wrote: ↑Sun Aug 16, 2020 10:53 amI am building a multi-player game. So I need to be able to have up to 4 separate "text logs". Is this possible?
Local multiplayer (i.e., on the same screen)? Or online?
Either way, I recommend getting one to work first. The example script above assumes one player because it sits on the Dialogue Manager GameObject.
Assuming local multiplayer, after you get one player to work, set up four dialogue UIs. Set up a GameObject for each player. Add an Override Dialogue UI to each player GameObject, and assign the corresponding dialogue UI. When you start a conversation for a player, make sure to specify the player's GameObject as the Conversation Actor.