how do i reference a text file in script?
I need to make a reference to "list 1" which is my text file but I do not know how please help
c+ using UnityEngine; using System.Collections; using UnityEngine.UI;
       public class opena: MonoBehaviour {
 
         public GameObject inputField;
         public string wordsFile = "c:\\file.list1.txt"; // EDIT THIS TO POINT TO YOUR FILE OF 60,000 WORDS
 
            void Start() {
             inputField = GameObject.Find("InputField"); //This is where you assign the input field object so you can access your inputField component
             inputField.GetComponent < InputField > (wordsFile).text = "list1"; //This makes it so the input field starts with nothing in it.
 
             string[] array = File.ReadLines().ToArray(); // This will load a text file into an array of strings
                 var hash = new HashSet < string > (array); // this converts the string array to a HashSet, could also use a dictionary for slightly better speed
         }
 
         void Update() {
             if (Input.GetKeyDown(KeyCode.Return)) { // Check for if they have hit enter 
                  
                 string input = inputField.GetComponent < InputField > ().text; // set a string to be what they entered
 
                 if (hash.Contains(input)) // check if the HashSet contains the code they entered 
                 {
                           // If they get here the code is correct
                     // i.e its in the list of 60,000 words
                     // do SOMETHING
                 } else {
                     // IF they get here... then they entered a WRONG CODe
                          // i.e not in the list of 60k words
                     // DO SOMETHING
                 }
             }
         }
          }
 
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
plz help me in Trivia Quiz Game Template setup 0 Answers
How to put the server to the player and client see be in the camera? 0 Answers
Loading Next Scene 2 Answers
CAMERAS ERROR , I NEED HELP 0 Answers