Question: Using unity and C# Create a StreamReader member variable for the script. Create an empty method called LoadGems( ) that takes in a string that
Using unity and C#
Create a StreamReader member variable for the script.
Create an empty method called LoadGems( ) that takes in a string that represents the file name. Don't hard-code it to "gem_data.txt". Inside of that method, bring the StreamReader variable to life, passing it the file name .
Below that, create a string called "dataline" and initialize it to the empty string ""
Immediately afterwards, read a line of data using the StreamReaders ReadLine() method.
This returns you the next available line in the file, so put it into "dataline".
While (dataline != null), print out dataline using Debug.Log() Inside that loop, read the next line of data.
At the bottom of the method (after the loop), close the file using sr.Close();
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
