Hello everyone,
My current project involves a fair amount of text, such as item descriptions, small conversations, etc…
Is it better to store all of the text in an encrypted “strings file”? Or can you get away with hard coding everything into the build?
Depends on what you want. Storing stuff like that externally in some kind of data file means you don’t have to compile your entire project for small changes. You’re also technically not touching code so it’s less riskier for non-programmers.
You might want to take a look at this:
// Import windows modules for .txt file creation.
import System.IO;
import System;
// Used to create .txt file containing the score of the level
function write(){
var score = guiObject.GetComponent(GUIScript).score;
sw = new StreamWriter(Application.dataPath + "Level3Score.txt"); // Level3Score.txt is the name is the .txt file to be created
sw.WriteLine(score);
sw.Close();
}
This function saves the score of the GUI object in one of my scenes to a text file inside the folder where the game files are located. Just call the function whenever needed. Libraries BUT be included for it to work.
Maybe you can tweak it to fit your needs.
Good luck!
You may want to look at using SqlLite to store the data. You can use collections and generic lists to manage it, or just plain SQL which is messy.
Unless you specifically need external files for modding purposes, it would simplify things just to use TextAssets rather than messing with System.IO classes.
–Eric
I should have been more specific. By “external” I meant “not declared as a const in a class file somewhere”. Sorry. 