using UnityEditor.UIElements; using UnityEngine.UIElements; namespace UnityEngine.Experimental.Perception.Editor { /// /// Derive this class to force the Unity Editor to render the default inspector using UIElements for an Object that includes a Parameter field. /// to allow parameter UIs to render properly /// public abstract class ParameterUIElementsEditor : UnityEditor.Editor { public override VisualElement CreateInspectorGUI() { var rootElement = new VisualElement(); CreatePropertyFields(rootElement); return rootElement; } void CreatePropertyFields(VisualElement rootElement) { var iterator = serializedObject.GetIterator(); iterator.NextVisible(true); do { if (iterator.name == "m_Script") continue; var propertyField = new PropertyField(iterator.Copy()); propertyField.Bind(serializedObject); rootElement.Add(propertyField); } while (iterator.NextVisible(false)); } } }