Hello everyone,
I am trying to extend the VisualTreeAsset inspector window to add some extra properties to a UXML file within the Unity Editor.
So far, I managed to add some labels and fields, but I noticed that the inputs are disabled (readonly).
I tried to call “EditorGUI.BeginDisabledGroup(false);” at the begining of the “OnInspectorGUI()” method, but that doesn’t help.
There’s my code to achieve this:
[CustomEditor(typeof(VisualTreeAsset))]
[CanEditMultipleObjects]
public class RosalinaUxmlDocumentInspector : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
VisualTreeAsset visualTreeAsset = (VisualTreeAsset)target;
string assetPath = AssetDatabase.GetAssetPath(visualTreeAsset.GetInstanceID());
var file = RosalinaSettings.instance.GetFileSetting(assetPath);
EditorGUI.BeginDisabledGroup(false);
EditorGUILayout.BeginVertical();
EditorGUI.BeginChangeCheck();
GUILayout.Space(20);
EditorGUILayout.LabelField("Rosalina", EditorStyles.boldLabel);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Enable");
bool test = EditorGUILayout.Toggle(file != null);
EditorGUILayout.EndHorizontal();
if (file != null)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Code generation type");
file.Type = (RosalinaGenerationType)EditorGUILayout.EnumPopup(file.Type);
EditorGUILayout.EndHorizontal();
}
if (EditorGUI.EndChangeCheck())
{
}
EditorGUILayout.EndVertical();
EditorGUI.EndDisabledGroup();
}
}
How can I enable these fields and that extension work with my settings system? Any ideas ?
Thanks,
Eastrall
