Hi all,
I'm in a bit of a pickle with my code. There are no errors thrown up with it but long story short my code won't put a variable in the UI text:
import System;
import System.IO;
import UnityEngine.UI;
var scorecounter : Text;
var fileName = "oofcount.txt";
var targetScript : Dupe;
function OnApplicationQuit()
{
var sr = File.CreateText(fileName);
targetScript.oofs -= 0;
sr.WriteLine (targetScript.oofs);
sr.Close();
if (File.Exists(fileName))
{
var sa = new StreamReader(fileName);
var fileContents = sa.ReadToEnd();
scorecounter.text = fileContents.ToString();
sa.Close();
}
}
As you can see near the bottom of the code, I'm trying to get fileContents to be saved into a UI text but whenever I initiate the function it's in (OnAppliactionQuit) the UI text stays blank. I have no idea why and I have tried all that I know.
Would appreciate any help or suggestions very much.
↧