Monobehaviour enabled property?

In the Unity Scripting>Runtime Classes>Monobehaviour info under Monobehaviour.OnGui, it states this:
“If the MonoBehaviour’s enabled property is set to false, OnGUI() will not be called.”
Where exactly is this setting? I am calling OnGui inside a script and it is not getting called. Everything else is getting called, but not OnGui.

OnGUI is called on its own if the script and game object are active.

If Update is called but not OnGUI, then the problem is not the script but that you have no camera with a guilayer component attached

OK. That was a fast reply! Now I have another dilemma though. I put the same code from the C# file that did not work, into a JScript file and made the small variable conversions, and it works like it’s supposed to. Why would this be?

because the code is not correct C# code. Coroutines as well as properties (transform.position or transform.rotation for example) work a bit different

It’s real simple code inside of OnGui like this:

var maxHealth = 100;
var curHealth = 100;
function OnGui() {
GUI.Box(new Rect(10,10, Screen.width / 2 / (maxHealth / curHealth), 20), curHealth + “/” + maxHealth);
};

Of course, the above is for JS, and for C# the function is replaced by void, and the two variables are int. OnGui would not run in a C# script but will inside of JS. I’m lost…

Hi there! Did you ever find an answer to this ?