创建两个脚本test和testEditor
public class test : MonoBehaviour
{
public string testName;
}
[CustomEditor(typeof(test))]
public class TestEditor : Editor
{
public VisualTreeAsset visualTree;
public override VisualElement CreateInspectorGUI()
{
VisualElement root = new VisualElement();
Foldout foldout = new Foldout() { text = "原始的参数" };
InspectorElement.FillDefaultInspector(foldout, serializedObject, this);
root.Add(foldout);
visualTree.CloneTree(root);
return root;
}
}
使用UIToolkit创建一个VisualTreeAsset,然后拖拽到TestEditor即可