Page 4 of 4
Re: Save in TXT file
Posted: Mon Feb 17, 2020 10:04 am
by Mchia_Soo
OH YES!!!! That's exactly what I want! This is actually like a simulation game for education where the player needs to collect the requirements from the NPCs. And what I want to save into txt file is the requirements collected by the player.
Anyways, thanks a lot Tony!!
Re: Save in TXT file
Posted: Mon Feb 17, 2020 12:48 pm
by Tony Li
Glad to help!
Re: Save in TXT file
Posted: Tue Feb 18, 2020 9:12 am
by Mchia_Soo
Hey Tony! Sorry for asking too many questions regarding this.
I just found out that this function is actually the same as Quest Journal, where it will replace the string when the quest state has changed.
Can I save the string value when the quest state is Active only? How should I fix it?
Re: Save in TXT file
Posted: Tue Feb 18, 2020 10:44 am
by Tony Li
I still don't understand. Can you provide some mock-up screenshots to illustrate what you want to do?
Re: Save in TXT file
Posted: Sat Feb 22, 2020 4:01 am
by Mchia_Soo
I'm using the same code you gave and apply it on 3 levels, but it can only save the latest level that has played.
Each level has 1 quest giver (Total 3 of them). I wanna save every quest giver's last conversation in all levels. How can I do it?
Re: Save in TXT file
Posted: Sat Feb 22, 2020 8:31 am
by Tony Li
You could try this to save each conversation in a separate file:
Code: Select all
void OnConversationEnd(Transform actor)
{
var filename = Application.persistentDataPath + "/" + DialogueManager.lastConversationStarted + ".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);
}
Or this to save each conversation according to its scene name:
Code: Select all
using UnityEngine.SceneManagement;
...
void OnConversationEnd(Transform actor)
{
var filename = Application.persistentDataPath + "/" + SceneManager.GetActiveScene().name + ".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);
}