So basically there are two parts to this problem. Firstly, I’m trying to use unity’s new (free) 2d support to make a GUI text object that will read out a number for testing purposes. Secondly the number I’m trying to display it with is currently being pulled from another class.
I’m just getting an error stating that “Assets/Scripts/FuelLSreadout.js(9,1): BCE0053: Property ‘UnityEngine.Component.guiText’ is read only.”
does that mean its impossible to get a live readout? Heres my code.
#pragma strict
public var fuel = 300.0f;
public var lifeSupport = 1000.0f;
function Start () {
}
function Update () {
guiText = "Life Support: " + lifeSupport + " | Fuel: " + fuel;
}
#pragma strict
public var fuel = 300.0f;
public var lifeSupport = 1000.0f;
public var (Whatever you wanna name it) : GUIText;
function Start () {
}
function Update () {
(Whatever you wanna name it).text = "Life Support: " + lifeSupport + " | Fuel: " + fuel;
}
I have no idea why this is the case, maybe I did something wrong. But I have at least several GUI displays in my project that do not work correctly if their info is update from inside Update().
Worst comes to worst you could try doing the update like in my example inside OnGUI();
Also your example doesn’t show how you’re trying to retrieve the data from the other script?
OnGUI code is not related to GUIText objects.
– Eric5h5