OnGUI / Text

Hi,

I found a tutorial that explains for Unity how to display a status text.
It uses an empty gameobject and attach the script below to display for example the health.
when i build and run, XCode tells me :Program received signal “SIGBUS” and the debug log shows me

End Load File completely 231.509333

Program received signal: “SIGBUS”.
(gdb)

any advice ?

private var playerStatus : PlayerStatus;

function Update () {
}

function awake () {
playerStatus = FindObjectOfType(PlayerStatus);
	
}

function OnGUI() {
	
	var health = playerStatus.GetHealth();
	
	GUI.Label(Rect(10,10,10,10), health.ToString());
	
}

SigBus Problem appear when the code do not find a variable value (or object …). Your fonction awake don’t work because it’s “Awake” no “awake”.

(If GetHealth is a Int or float or text) :

private var playerStatus : PlayerStatus; 

function Update () { 
} 

function Awake () { //No awake, but Awake
playerStatus = FindObjectOfType(PlayerStatus); 
    
} 

function OnGUI() { 
    
   GUI.Label(Rect(10,10,40,40), playerStatus.GetHealth.ToString()); 
    
}

You must have a script with name PlayerStatus on the project/scene.