#pragma once #include "UI/UI.h" #include #include namespace XCEngine { namespace Editor { namespace ComponentEditorAssetUI { struct AssetReferenceInteraction { std::string assignedPath; bool clearRequested = false; }; inline AssetReferenceInteraction DrawAssetReferenceProperty( const char* label, const std::string& currentPath, const char* emptyHint, std::initializer_list supportedExtensions) { AssetReferenceInteraction interaction; const std::string popupTitle = std::string("Select ") + (label ? label : "Object"); UI::ReferencePickerOptions pickerOptions; pickerOptions.popupTitle = popupTitle.c_str(); pickerOptions.emptyHint = emptyHint; pickerOptions.searchHint = "Search"; pickerOptions.noAssetsText = "No compatible assets."; pickerOptions.noSceneText = "No compatible scene objects."; pickerOptions.assetsTabLabel = "Assets"; pickerOptions.sceneTabLabel = "Scene"; pickerOptions.showAssetsTab = true; pickerOptions.showSceneTab = false; pickerOptions.supportedAssetExtensions = supportedExtensions; UI::DrawPropertyRow(label, UI::InspectorPropertyLayout(), [&](const UI::PropertyLayoutMetrics& layout) { UI::AlignPropertyControlVertically(layout, ImGui::GetFrameHeight()); const UI::ReferencePickerInteraction pickerInteraction = UI::DrawReferencePickerControl( currentPath, ::XCEngine::Components::GameObject::INVALID_ID, pickerOptions, layout.controlWidth); interaction.assignedPath = pickerInteraction.assignedAssetPath; interaction.clearRequested = pickerInteraction.clearRequested; return false; }); return interaction; } } // namespace ComponentEditorAssetUI } // namespace Editor } // namespace XCEngine