Read words into list on startup

This commit is contained in:
lvrossem
2023-02-28 12:24:46 +01:00
parent ef58f9bb19
commit 4fdfd0da84
9 changed files with 979 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class SpellingBeeController : MonoBehaviour
{
private List<string> lines;
// Start is called before the first frame update
void Start() {
lines = new List<string>();
string path = "Assets/SpellingBee/words.txt";
StreamReader reader = new StreamReader(path);
string line = "";
while ((line = reader.ReadLine()) != null) {
lines.Add(line);
}
}
// Update is called once per frame
void Update() {
int randomIndex = UnityEngine.Random.Range(0, lines.Count);
string randomWord = lines[randomIndex];
Debug.Log(randomWord);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 44fbed5ae228de39b9f727def7578d06
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: