Okay, so I’m running into some issues here. So let me explain what I’m trying to do:
I’m trying to make a development log record system, that pulls information from certain lines of a .txt file and replaces the text on a TextMeshPro element. I’ve figured out how to change the text, and I’m now trying to figure out how to pull line 5 from a text file.
Each devlog has a number, and the search system searches for the number of the file, and pulls line five from it to change the devlog textbox. The plan is to change the search number by 1 depending on the key pressed, and then search for a devlog matching the new number, and then change the current TextMeshPro elements onscreen. Note: the method that changes the number hasn’t been created yet, but the variables for it have.
Now, I’m almost positive that I have the filepath of the devlogs correct. And there’s tons of different websites with convoluted statements on how to use the File.ReadLines script, so my guess is that I’m getting the formatting wrong, or something else that’s either really simple, or really difficult.
It keeps giving me a bunch of error messages, and no matter how many changes I try, it just seems to add more. Honestly, at this point, I’m stuck, so I’m asking for help on here.
Here is the code, for reference.
using System.Collections.Generic;
public class DevlogChanger : MonoBehaviour
{
public TMP_Text CanvasText;
string DVLGFilePath;
public int Entry;
public int EntrySearch;
string[] DVLGLinesArray;
// Start is called before the first frame update
void Start()
{
Entry = 1;
EntrySearch = 1;
DVLGFilePath = Application.dataPath + "/" + "Devlogs" + "/" + "1" + ".txt";
}
public void SearchForEntry(string DVLGFilePath, int EntrySearch)
{
//search for file matching new int
DVLGFilePath = Application.dataPath + "/" + "Devlogs" + "/" + EntrySearch + ".txt";
}
public void UpdateDevlogText(string DVLGFilePath, int EntrySearch)
{
IEnumerable<EntrySearch>, File.ReadLines(DVLGFilePath, path);
foreach (string line in DVLGLinesArray)
{
print(line);
}
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
CanvasText.text = "output from line search will be put here";
}
}
