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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started