工具变体用于将逻辑上类似的工具分组到工具覆盖层中的单个按钮中。
variantGroup 类型充当指定应在 UI 中视为一组的工具组的键。
using System; using UnityEditor; using UnityEditor.EditorTools; using UnityEngine; namespace GlobalToolVariants { // Define 3 tools that should be shown as a single button in the Tools Overlay. struct ShapeVariantGroup {} [EditorTool("Line (Custom Global)", variantGroup = typeof(ShapeVariantGroup), variantPriority = 2)] [Icon("Assets/Examples/Icons/Variant-Line.png")] class Line : EditorTool {} [EditorTool("Circle (Custom Global)", variantGroup = typeof(ShapeVariantGroup), variantPriority = 1)] [Icon("Assets/Examples/Icons/Variant-Circle.png")] class Circle : EditorTool {} [EditorTool("Square (Custom Global)", variantGroup = typeof(ShapeVariantGroup), variantPriority = 0)] [Icon("Assets/Examples/Icons/Variant-Square.png")] class Square : EditorTool {} }