Im using the following code, all i need is the right if construct (commented in the code)
using UnityEngine;
using System.Collections;
public class Check : MonoBehaviour {
public Camera cam;
public bool enabled=false ;
public Component target;
void Update () {
//if (!enabled)
//{
// GetComponent(target) = false;
//}
}
void OnGUI () {
enabled = GUI.Toggle(new Rect(0,0,100,100), false, "Enable");
}
}
Every MonoBehaviour has an inherited member variable called enabled which enables/disables a component. You can use this on the script.
SomeScript script = target.GetComponent<SomeScript>();
script.enabled = toggleBoolean;