Small refactor to use Resource folder
This commit is contained in:
8
Assets/Resources.meta
Normal file
8
Assets/Resources.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bcb514437f9c35faaac228c5b6583838
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
Before Width: | Height: | Size: 261 KiB After Width: | Height: | Size: 261 KiB |
|
Before Width: | Height: | Size: 257 KiB After Width: | Height: | Size: 257 KiB |
@@ -5,24 +5,19 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class SpellingBeeController : MonoBehaviour
|
public class SpellingBeeController : MonoBehaviour
|
||||||
{
|
{
|
||||||
private List<string> lines;
|
private string[] words;
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start() {
|
void Start() {
|
||||||
lines = new List<string>();
|
TextAsset textFile = Resources.Load<TextAsset>("SpellingBee/words");
|
||||||
|
string fileContents = textFile.text;
|
||||||
string path = "Assets/SpellingBee/words.txt";
|
|
||||||
StreamReader reader = new StreamReader(path);
|
|
||||||
|
|
||||||
string line = "";
|
words = fileContents.Split('\n');
|
||||||
while ((line = reader.ReadLine()) != null) {
|
|
||||||
lines.Add(line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update() {
|
void Update() {
|
||||||
int randomIndex = UnityEngine.Random.Range(0, lines.Count);
|
int randomIndex = UnityEngine.Random.Range(0, words.Length - 1);
|
||||||
string randomWord = lines[randomIndex];
|
string randomWord = words[randomIndex];
|
||||||
|
|
||||||
Debug.Log(randomWord);
|
Debug.Log(randomWord);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user