Good Afternoon, I am trying to disable a editor toggle button in the inspector by code and make it not clickable. Thanks for all your help.
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor (typeof (Tester))]
public class Test : Editor {
private bool test;
public override void OnInspectorGUI() {
test = EditorGUILayout.Toggle("test", test);
}
}
using UnityEditor;
[CustomEditor (typeof (Tester))]
public class Test : Editor {
bool test;
bool disabled;
Tester tester;
void OnEnable(){
tester = (Tester)target;
}
public override void OnInspectorGUI() {
test = EditorGUILayout.Toggle("test", test);
EditorGUI.BeginDisabledGroup (test == false);
disabled = EditorGUILayout.Toggle("disabled", disabled);
EditorGUI.EndDisabledGroup ();
}
}