How to : enable/disable OnGUI() script on C#

void OnGUI () {

if ( GUI.Button ( new Rect ( 3,100, 200, 30 ), “Quit Finding”))

TeleportLocation code = GetComponent<TeleportLocation>();
code.enabled = false;
ButtonContent scan = GetComponent<ButtonContent>();
scan.enabled = true;


The type or namespace name `ButtonContent’ could not be found. Are you missing a using directive or an assembly reference?

All of this script were attached in FPS.

First you don’t need to use GetComponent to access the current instance of TeleportLocation. Your class IS a TeleportLocation so by writing

enabled = false;

You will disable this script.

Your actual problem is that it seems you don’t have this “ButtonContent” class. Are you sure you have a script that is called ButtonContent? And also make sure it’s attached to the same object or GetComponent will fail.

Anyway, the error can’t be misinterpreted: the compiler can’t find a class that is called ButtonContent.

Can you explain what Buttoncontext should be?