- Home /
Question by
bradleyKern · Jun 27, 2018 at 06:01 PM ·
editorguilayout
Custom Inspector GUILayout Elements Greyed Out and Uninteractable?
I am creating a custom inspector for SceneAssets but every single GUILayout element I create is greyed out and unable to be interacted with. For example, I can do:
"GUILayout.Button("Hello")"
And the button will appear in the inspector but will be greyed out and not clickable. Here is a basic script that is having this problem:
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
#if UNITY_EDITOR
[CustomEditor(typeof(SceneAsset))]
public class SceneLockingEditor : Editor
{
SceneAsset scene;
public Texture lockedTex;
public Texture unlockedTex;
bool locked;
private void OnEnable()
{
scene = (SceneAsset)target;
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if (scene)
{
GUILayout.Label(scene.name);
if (locked)
{
if(GUILayout.Button(lockedTex, GUILayout.Width(200), GUILayout.Height(200)))
{
locked = false;
Debug.Log("unlocked");
}
}
else
{
if (GUILayout.Button(unlockedTex, GUILayout.Width(200), GUILayout.Height(200)))
{
locked = true;
Debug.Log("locked");
}
}
}
}
}
#endif
I haven't found anyone else with this problem. I've made plenty of custom inspectors before without this issue. How can I make my buttons interactable?
Comment