You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class MyProjectScript : EditorTool
{
public override void OnToolGUI()
{
// ... ?
}
}
Old Way
class MyProjectScript : EditorTool
{
OverlayWindow m_Overlay;
void OnEnable()
[
m_Overlay = new OverlayWindow(
new GUIContent("My Overlay"),
OverlayGUI,
int.MaxValue,
null,
SceneViewOverlay.WindowDisplayOption.MultipleWindowsPerTarget);
}
public override void OnToolGUI()
{
SceneViewOverlay.ShowWindow(m_Overlay);
}
void OverlayGUI(Object target, SceneView sceneView)
{
GUILayout.Label("hello!");
}
}
Old Way
Old Way
IMGUI only
Anchored to bottom right of screen
Not resizable
Internal API
No consistency for third party tools
New API
Class implementing Overlay
Tagged with OverlayAttribute
New API
publicabstractclassOverlay{// Less interesting properties omittedpublicUnityEditor.EditorWindowcontainerWindow{get;}publicbooldisplayed{get;set;}publicstringdisplayName{get;set;}publicboolfloating{get;}publicUnityEngine.Vector2floatingPosition{get;set;}publicstringid{get;}publicabstractVisualElementCreatePanelContent();protectedvirtualvoidOnCollapsed();publicvirtualvoidOnDestroy();protectedvirtualvoidOnExpanded();publicvirtualvoidOnInitialize();publicvirtualvoidOnPopupWindowDestroy(EditorWindowwindow);publicvirtualvoidOnPopupWindowInitialize(EditorWindowwindow);publicvoidUndock();}
Register Overlay as applicable to Scene View, with display name.
IconAttribute is not specific to Overlay. It is a simple way to define an icon for a MonoBehaviour that respects the built-in naming conventions (ex, "d_" and "@2x")
Not required
If no Icon is found the Overlay will create one from first two significant letters.
Just a VisualElement that is styled correctly for a toolbar
We provide out of the box a set of default elements (EditorToolbar{Button, Toggle, Dropdown, ...})
Can author custom VisualElement as well
IAccessContainerWindow provides access to the Overlay.containerWindow
Toolbars (EditorToolbarElement)
publicSceneLightingElement(){name="SceneviewLighting";tooltip=L10n.Tr("When toggled on, the Scene lighting is used. When toggled off, a light attached to the Scene view camera is used.");RegisterCallback<AttachToPanelEvent>(OnAttachedToPanel);RegisterCallback<DetachFromPanelEvent>(OnDetachFromPanel);this.RegisterValueChangedCallback(evt =>sceneView.sceneLighting=evt.newValue);SceneViewToolbarElements.AddStyleSheets(this);}// ... implementation
Otherwise this is authored exactly like a typical VisualElement