- Home /
Updating an interger in a GUIText
Hey so im having a little problem with this code.
var gText1: GUIText;
var gText2: GUIText;
var gameHolder : GameObject;
var flashlightObj : Light;
function Update(){
gText1.text = gameHolder.GetComponent(NewerGameScript).totalNotebooks;
gText2.text = flashlightObj.GetComponent(FlashlightBattery).batteryLife;
}
When i use this script it gives me an error that says "Cannot convert 'int' to 'String'." so how can i show an interger on a string?
Comment
Best Answer
Answer by ScroodgeM · Jul 28, 2012 at 06:49 PM
cast it to string
gText1.text = gameHolder.GetComponent(NewerGameScript).totalNotebooks.ToString(); gText2.text = flashlightObj.GetComponent(FlashlightBattery).batteryLife.ToString();
it took away the error but now i get this error when i play the game: "$$anonymous$$ethod not found: 'System.Int32.toString'."
Your answer
Follow this Question
Related Questions
Setting an int through function update 2 Answers
Check if a guiText = a number? 2 Answers
Timer lag at GUIText drawing. 1 Answer
Update call for Multiple GUIText fails 1 Answer
GUI Text to GUI Label Script? 1 Answer