在自定义检查器中隐藏检查器时无法查看列表的子项

Cant view children of a list when hideininspector in custom inspector

我在 Unity 中遇到了一点问题,所以我制作了一个列表和一个布尔值

and i scripted it so that when the bool is pressed, the list is revealed

And here, you can see that i can open the list with no problem and view the contents

但是,我希望原件不显示,所以我添加了 [HideInInspector]

But now when i press the bool, it shows the list, BUT, i cant view nor edit the content of list

我该如何解决这个问题? 谢谢!
P.S: 这是我的代码

public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        QuizManager myScript = target as QuizManager;
        if (myScript.ShowList) {
            var property = serializedObject.FindProperty("AList");

            serializedObject.Update();

            EditorGUILayout.PropertyField(property,true);
        }
    }

我想您的问题与使用 [HideInInspector] 有关。我可以为您的麻烦提出几个可能的解决方案:

  1. 尽量不要使用 [HideInInspector] 并从您的代码中删除 DrawDefaultInspector()。只需为 class 中的所有属性设置 EditorGUILayout.PropertyField(),然后您就可以根据需要添加此 bool 变量。
  2. 尝试使用 here 中描述的技术。
  3. 尝试使用CustomPropertyDrawer,您可以获取官方信息here and here