[英]Can't use DecoratorDrawer with ScriptableObject in Unity
[英]Stop Unity Inspector DecoratorDrawer chaining
當您連續聲明多個變量時,它們會接收所有屬性。
寫入 [Space(10)] 不會在檢查器中此時添加空間,但會使用序列化程序拾取的屬性裝飾字段,從而導致不同的布局。 但是,此屬性將分配給所有字段,從而產生您獲得的布局。 所以不,我不認為你可以這樣做。
Odin Inspector具有這樣的分組功能,但來自 Unity 的功能仍然會像您的問題一樣。
一般來說,為什么在提問時不上傳代碼/錯誤的圖像? .
然后一般來說,我個人也不會使用多個內聯聲明。 這是可維護性/可讀性較差的方式。
如您所見,多個內聯聲明意味着屬性應用於每個單獨的字段/屬性。
所以基本上你的
[Header("Start points of the arrow")]
[SerializeField] private GameObject arrowpoint_joystick, arrowpoint_trigger, arrowpoint_secondary;
等於寫作
[Header("Start points of the arrow")][SerializeField] private GameObject arrowpoint_joystick;
[Header("Start points of the arrow")][SerializeField] private GameObject arrowpoint_trigger;
[Header("Start points of the arrow")][SerializeField] private GameObject arrowpoint_secondary;
這當然不是你想要做的。
代替
[Header("Start points of the arrow")]
[SerializeField] private GameObject arrowpoint_joystick, arrowpoint_trigger, arrowpoint_secondary;
[Space(10)]
[Header("List of secondary bezier points")]
[SerializeField] private GameObject arrowpoint_joystickBezierPoint, arrowpoint_triggerBezierPoint, arrowpoint_secondaryBezierPoint;
我寧願做到
[Header("Start points of the arrow")]
[SerializeField] private GameObject arrowpoint_joystick;
[SerializeField] private GameObject arrowpoint_trigger;
[SerializeField] private GameObject arrowpoint_secondary;
[Space(10)]
[Header("List of secondary bezier points")]
[SerializeField] private GameObject arrowpoint_joystickBezierPoint;
[SerializeField] private GameObject arrowpoint_triggerBezierPoint
[SerializeField] private GameObject arrowpoint_secondaryBezierPoint;
和(兩者)“問題”(和意見)已經解決,而且這種方式在代碼中看起來更類似於它在檢查器中的樣子。 而且不需要外部庫。 (Odin 有時會因為它的“神奇”序列化而帶來其他問題;))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.