Hello! I’m working with a password system for “Computers” in my game. I want to make it so you can add and save passwords to the system. After a lot of tedious work, I got to a point where I use string.Join to turn my list of strings into one string. I then load my string, where I want to split it and turn it into a list. I will then use that list and set the list of codes. The only issue is I can’t split the string in the List.Add function, and I don’t believe I can add an array to a list. If anyone could help, here is the code:
private const string seperator = “!SEPARATE_VALUES!”;
public GameObject disableSelf;
public GameObject loadNextOne;
public GameObject loadNextTen;
// Stored Strings
public List<string> codesLvlOne;
public List<string> codesLvlTwo;
public List<string> codesLvlThree;
public List<string> codesLvlFour;
public List<string> codesLvlFive;
public List<string> codesLvlSix;
public List<string> codesLvlSeven;
public List<string> codesLvlEight;
public List<string> codesLvlNine;
public List<string> codesLvlTen;
//Load Strings
private List<string> codesLOne;
private int i = 0;
void Start () {
string CodesOne = File.ReadAllText(Application.dataPath + "/SaveData/passwordListOne.txt");
string[] splitCodesOne = CodesOne.Split(new[] { seperator }, System.StringSplitOptions.None)
while (i <= splitCodesOne.Length) {
codesLvlOne.Add(splitCodesOne*);*
-
i++;*
-
}*
- }*
- void OnApplicationQuit () {*
-
SavePasswords();*
- }*
- public static void SavePasswords () {*
-
List<string> CodesLOne = string.Join(seperator, codesLvlOne);*
-
File.WriteAllText(Application.dataPath + "/SaveData/passwordListOne.txt", CodesLOne);*
- }*