Game.UI.Editor.LoadAssetPanel
Assembly: Game
Namespace: Game.UI.Editor
Type: class
Base: EditorPanelBase
Summary:
LoadAssetPanel is an editor UI panel used to present a searchable list of assets to the user and allow them to pick one to load. It composes a SearchField, an ItemPicker
Fields
-
public delegate void LoadCallback(Hash128 guid)
Delegate type invoked when the user confirms a selection. Receives the selected asset's Hash128 guid. -
private LoadCallback m_ConfirmCallback
Holds the callback provided by the caller to be invoked when the user confirms (presses the "Load" button). -
private AssetPickerAdapter m_Adapter
Adapter instance that provides data and selection state to the SearchField, ItemPicker and footer widgets. It exposes the currently selected AssetItem via m_Adapter.selectedItem.
Properties
- None (no public properties are defined on this class).
Constructors
public LoadAssetPanel(LocalizedString panelTitle, IEnumerable<AssetItem> items, LoadCallback onConfirm, Action onClose)
Creates a new LoadAssetPanel instance.- panelTitle: localized title shown at the top of the panel.
- items: collection of AssetItem entries to display in the picker.
- onConfirm: LoadCallback invoked with the selected asset guid when the user confirms.
- onClose: Action invoked when the user cancels/closes the panel. Behavior:
- Initializes an AssetPickerAdapter with the provided items.
- Builds the panel's child widgets:
- SearchField wired to the adapter for filtering.
- ItemPicker
wired to the adapter with hasFavorites = true. - ItemPickerFooter wired to the adapter.
- Button row with two buttons:
- "Editor.LOAD": disabled while no item is selected, calls OnConfirm when pressed.
- "Common.CANCEL": calls the provided onClose action.
Methods
private void OnConfirm()
Invoked by the "Load" button. Calls the stored m_ConfirmCallback with the guid of the currently selected asset:- m_ConfirmCallback(m_Adapter.selectedItem.guid) Note: The "Load" button is disabled when m_Adapter.selectedItem is null, so this method assumes a non-null selectedItem when invoked.
Usage Example
// Example: creating and showing a LoadAssetPanel
IEnumerable<AssetItem> availableAssets = GetAllAssetsSomehow();
LocalizedString title = new LocalizedString("Editor.SELECT_ASSET");
var panel = new LoadAssetPanel(
title,
availableAssets,
onConfirm: (Hash128 guid) =>
{
// Called when user selects an asset and presses Load
LoadAssetByGuid(guid);
},
onClose: () =>
{
// Called when user cancels/closes the panel
ClosePanel();
}
);
// Add panel to your editor UI container (pseudo-code)
EditorUI.ShowPanel(panel);