Table of Contents

Class BasePanel

Namespace
Core.UI
Assembly
Core.dll

ENGINE - Base class for UI Toolkit panels. Provides common infrastructure: UIDocument access, root element, show/hide.

Usage:

  1. Inherit from BasePanel
  2. Override CreateUI() to build your panel
  3. Call Initialize() to set up the panel
[RequireComponent(typeof(UIDocument))]
public abstract class BasePanel : MonoBehaviour
Inheritance
object
BasePanel
Derived

Fields

isInitialized

protected bool isInitialized

Field Value

bool

isVisible

protected bool isVisible

Field Value

bool

panelContainer

protected VisualElement panelContainer

Field Value

VisualElement

rootElement

protected VisualElement rootElement

Field Value

VisualElement

uiDocument

protected UIDocument uiDocument

Field Value

UIDocument

Properties

IsInitialized

True if panel has been initialized.

public bool IsInitialized { get; }

Property Value

bool

IsVisible

True if panel is currently visible.

public bool IsVisible { get; }

Property Value

bool

Methods

CenterPanel()

Center the panel on screen.

protected void CenterPanel()

CreatePanelContainer(string, Color, float, float)

Create the main panel container with common styling.

protected VisualElement CreatePanelContainer(string name, Color backgroundColor, float padding = 10, float borderRadius = 6)

Parameters

name string
backgroundColor Color
padding float
borderRadius float

Returns

VisualElement

CreateUI()

Override to create your panel's UI elements. Set panelContainer to your main container element.

protected abstract void CreateUI()

Hide()

Hide the panel.

public virtual void Hide()

InitializeBase()

Initialize the panel. Call from subclass Initialize() method.

protected bool InitializeBase()

Returns

bool

OnHide()

Called when panel is hidden. Override for cleanup.

protected virtual void OnHide()

OnShow()

Called when panel is shown. Override for refresh logic.

protected virtual void OnShow()

PositionPanel(float?, float?, float?, float?)

Position the panel absolutely.

protected void PositionPanel(float? top = null, float? right = null, float? bottom = null, float? left = null)

Parameters

top float?
right float?
bottom float?
left float?

Show()

Show the panel.

public virtual void Show()

Toggle()

Toggle panel visibility.

public virtual void Toggle()