Custom GUI
Custom editor GUI
using UnityEngine.UIElements;
#if UNITY_EDITOR
using UnityEditor.UIElements;
#endif
[DataObjectHideAllFields]
public class EnemyData : DataObject
{
public int health;
public float speed;
#if UNITY_EDITOR
// Override CustomGUI to create custom GUI for this DataObject
public override VisualElement EditorGUI(SerializedObject _serializedObject, DatabrainEditorWindow _editorWindow)
{
// Create a root container
var _root = new VisualElement();
// Lets add a label
var _label = new Label();
_label.text = "Enemy Data";
_label.style.fontSize = 14;
// Add label to the root
_root.Add(_label);
// Add both properties
var _healthProp = new PropertyField();
_healthProp.BindProperty(_serializedObject.FindProperty(nameof(health)));
var _speedProp = new PropertyField();
_speedProp.BindProperty(_serializedObject.FindProperty(nameof(speed)));
_root.Add(_healthProp);
_root.Add(_speedProp);
// Return the main container
return _root;
}
#endif
}Custom runtime GUI
Last updated