Read words into list on startup
This commit is contained in:
29
Assets/Scripts/SpellingBeeController.cs
Normal file
29
Assets/Scripts/SpellingBeeController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SpellingBeeController.cs.meta
Normal file
11
Assets/Scripts/SpellingBeeController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44fbed5ae228de39b9f727def7578d06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user