这是我的Example类和MonoBehaviour脚本:
using UnityEngine;
using System;
[Serializable]
public class TestSerializableClass
{
public int a;
public string b;
}
public class TestScript : MonoBehaviour
{
public TestSerializableClass field1;
[HideInInspector] public TestSerializableClass field2;
}
这是MonoBehaviour脚本的编辑器脚本
using UnityEditor;
[CustomEditor(typeof(TestScript))]
public class TestScriptEditor : Editor
{
SerializedProperty testClass;
public override void OnInspectorGUI()
{
DrawDefaultInspector();
SerializedProperty testField = serializedObject.FindProperty("field2");
EditorGUILayout.PropertyField(testField, true);
}
}
This is how my inspector for TestScript looks.
为什么不像第一个那样绘制“field2”变量?
我可以使用编辑器脚本和属性字段吗?怎么样?
(includeChildre标志为true)
答案 0 :(得分:0)
从field2中删除HideInInspector属性