如何在Unity Inspector中隐藏超类的变量?

问题描述 投票:0回答:1

我定义了一个名为 LLM 的超类,并将其一些变量设置为“[SerializeField]”,因为我希望在某些子类的脚本中的 Inspector 窗口中修改它们。现在我想创建一个从超类继承的子类,但我希望超类中的一些“[SerializeField]”变量不要显示在检查器窗口中。我该如何处理这个问题?

我要求ChatGPT 3.5找到一些解决方案,然后我尝试了这个

[HideInInspector] protected new string m_Prompt;
,但出现了这个错误
The same field name is serialized multiple times in the class or its parent class. This is not supported: Base(LangChainSpark) m_Prompt

c# unity-game-engine superclass
1个回答
0
投票

我认为你可能需要为子类编写一个自定义编辑器,然后你可以控制显示的内容。

https://docs.unity3d.com/Manual/editor-CustomEditors.html

© www.soinside.com 2019 - 2024. All rights reserved.