Save in TXT file
Re: Save in TXT file
And thanks for the information. Now that I know there are 2 save systems we can use.
Re: Save in TXT file
Yes. I'm assuming that your Save System has a JsonDataSerializer. QuestJournal.RecordData() creates a serializable object. Then it uses the DataSerializer on the Save System to serialize it. If the Save System has a JsonDataSerializer, it will serialize the object to JSON.
Re: Save in TXT file
Hi,
I'm referring to the Save System component. When you tell it to record savegame data, it tells all of the Savers in the scene to record their data. Then it stores all of the Savers' data in a dictionary (a SavedGameData object).
I'm referring to the Save System component. When you tell it to record savegame data, it tells all of the Savers in the scene to record their data. Then it stores all of the Savers' data in a dictionary (a SavedGameData object).
Re: Save in TXT file
But there's no checkbox for Quest Journal's Save Settings. Where can I find those checkboxes?
Re: Save in TXT file
In the Quest Journal component's Save Settings foldout:
Re: Save in TXT file
Still don't have any idea to solve it.
Just realize that you did mention before about ConversationLogger.cs. I have modified the script to save the conversation in txt file.
But I got this error while the game is playing.
UnauthorizedAccessException: Access to the path "C:\saved.txt" is denied.
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
And my script is like this (I only edited the script in OnConversationLine method):
Am I editing at the right place?
Just realize that you did mention before about ConversationLogger.cs. I have modified the script to save the conversation in txt file.
But I got this error while the game is playing.
UnauthorizedAccessException: Access to the path "C:\saved.txt" is denied.
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <f826c2584fc94ec19a48a6576640bdc5>:0)
And my script is like this (I only edited the script in OnConversationLine method):
Code: Select all
public void OnConversationLine(Subtitle subtitle)
{
if (subtitle == null | subtitle.formattedText == null | string.IsNullOrEmpty(subtitle.formattedText.text)) return;
string speakerName = (subtitle.speakerInfo != null && subtitle.speakerInfo.transform != null) ? subtitle.speakerInfo.transform.name : "(null speaker)";
string data = string.Format("<color={0}>{1}: {2}</color>", new object[] { GetActorColor(subtitle), speakerName, subtitle.formattedText.text });
Debug.Log(data);
System.IO.File.WriteAllText("/saved.txt", data);
}
Re: Save in TXT file
Hi,
I'm still not sure what you ultimately want to do. But if you want to save a transcript of a conversation, you can do something similar to ConversationLogger. You don't have to customize the ConversationLogger script itself. If you import an update to the Dialogue System, it could overwrite your customizations. Try adding a script like this to your Dialogue Manager:
ConversationTranscript.cs
This will save a transcript of the conversation to a file in the application's persistent data path.
I'm still not sure what you ultimately want to do. But if you want to save a transcript of a conversation, you can do something similar to ConversationLogger. You don't have to customize the ConversationLogger script itself. If you import an update to the Dialogue System, it could overwrite your customizations. Try adding a script like this to your Dialogue Manager:
ConversationTranscript.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class ConversationTranscript : MonoBehaviour
{
private string transcript;
void OnConversationStart(Transform actor)
{
transcript = DialogueManager.lastConversationStarted + ":";
}
void OnConversationLine(Subtitle subtitle)
{
transcript += "\n" + subtitle.formattedText.text;
}
void OnConversationEnd(Transform actor)
{
var filename = Application.persistentDataPath + "/transcript.txt");
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
filename = filename.Replace("/", "\\"); // Windows uses backslash.
#endif
System.IO.File.WriteAllText(filename, transcript);
}
}
Re: Save in TXT file
Try adding this line:
(I had a typo in the script that I just fixed. It had "#else" but it should be "#endif".)
After you add that line and try again, it will log the filename to the Console.
Code: Select all
void OnConversationEnd(Transform actor)
{
var filename = Application.persistentDataPath + "/transcript.txt");
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
filename = filename.Replace("/", "\\"); // Windows uses backslash.
#endif
Debug.Log("Saving: " + filename); //<-- ADD THIS LINE.
System.IO.File.WriteAllText(filename, transcript);
}
After you add that line and try again, it will log the filename to the Console.