在 叠加层属性 中使用 DockPosition 设置叠加层的默认位置。
using UnityEditor; using UnityEditor.Overlays; using UnityEngine; using UnityEngine.UIElements;
// Use OverlayAttribute to specify that in new Scene Views, when this Overlay is first opened it will be in the // top toolbar, aligned to the left side. [Overlay(typeof(SceneView), "Docked Top Toolbar, Left Aligned", defaultDockZone = DockZone.TopToolbar, defaultDockPosition = DockPosition.Top)] class MyOverlay : Overlay { public override VisualElement CreatePanelContent() => new Label("Overlay Contents"); }