在 parent 类 inspector 中统一隐藏 headers 和变量
Hide headers and variables in inspector from parent classes in unity
我有一个class"Weapon"和一个子class"ThrowableWeapon"。我想在第二个的检查器中隐藏一些从 parent 继承的变量和 headers。可能吗?
我还想修改 parent 中某些 public 变量的默认值,并在 child 的检查器中将新值显示为默认值,但我可以看看怎么做。如果我更改 child 的 Start 方法中的值,检查器中的默认值仍然是 parent 的默认值。
谢谢。
如果您想隐藏父级的序列化字段,您将必须创建一个 Custom inspector 并检索派生的 class.
的字段
如果你想"override"导出class中的默认值,我能想到的唯一方法是实现MonoBehaviour's Reset
函数并在此处设置所需的值。
Reset is called when the user hits the Reset button in the Inspector's context menu or when adding the component the first time. This function is only called in editor mode. Reset is most commonly used to give good default values in the inspector.
void Reset()
{
parentAttribute = newValue ;
}
我有一个class"Weapon"和一个子class"ThrowableWeapon"。我想在第二个的检查器中隐藏一些从 parent 继承的变量和 headers。可能吗?
我还想修改 parent 中某些 public 变量的默认值,并在 child 的检查器中将新值显示为默认值,但我可以看看怎么做。如果我更改 child 的 Start 方法中的值,检查器中的默认值仍然是 parent 的默认值。
谢谢。
如果您想隐藏父级的序列化字段,您将必须创建一个 Custom inspector 并检索派生的 class.
的字段如果你想"override"导出class中的默认值,我能想到的唯一方法是实现MonoBehaviour's Reset
函数并在此处设置所需的值。
Reset is called when the user hits the Reset button in the Inspector's context menu or when adding the component the first time. This function is only called in editor mode. Reset is most commonly used to give good default values in the inspector.
void Reset()
{
parentAttribute = newValue ;
}