浏览代码

added derivable default UI elements editor

/main
Steven Leal 4 年前
当前提交
4d058c69
共有 4 个文件被更改,包括 38 次插入0 次删除
  1. 3
      com.unity.perception/Editor/Utilities.meta
  2. 32
      com.unity.perception/Editor/Utilities/DefaultUIElementsEditor.cs
  3. 3
      com.unity.perception/Editor/Utilities/DefaultUIElementsEditor.cs.meta

3
com.unity.perception/Editor/Utilities.meta


fileFormatVersion: 2
guid: 7c33b05b860544a5a026b97302d0358e
timeCreated: 1611791860

32
com.unity.perception/Editor/Utilities/DefaultUIElementsEditor.cs


using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEngine.Experimental.Perception.Editor
{
/// <summary>
/// Derive this class to force the Unity Editor to render an Object's default inspector using UIElements
/// </summary>
public abstract class DefaultUIElementsEditor : 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));
}
}
}

3
com.unity.perception/Editor/Utilities/DefaultUIElementsEditor.cs.meta


fileFormatVersion: 2
guid: ec638a81755645739ca5834e2e44fc13
timeCreated: 1611791890
正在加载...
取消
保存