添加简单文件资产视图, 添加资源拖拽功能

This commit is contained in:
2025-06-11 00:22:53 +08:00
parent f4aa895bbb
commit 91af2392ed
15 changed files with 194 additions and 10 deletions

View File

@ -3,6 +3,8 @@
//
#include "SceneHierachyPanel.h"
#include <filesystem>
#include <imgui.h>
#include <imgui_internal.h>
#include <glm/gtc/type_ptr.hpp>
@ -10,6 +12,8 @@
namespace Hazel
{
extern const std::filesystem::path g_AssetPath;
SceneHierachyPanel::SceneHierachyPanel(const Ref<Scene>& context)
{
SetContext(context);
@ -336,6 +340,21 @@ namespace Hazel
DrawComponent<SpriteRendererComponent>("Sprite Renderer", entity, [](auto& component)
{
ImGui::ColorEdit4("Color", glm::value_ptr(component.Color));
// Texture
ImGui::Button("Texture", ImVec2(100.f, 0.0f));
if (ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("CONTENT_BROSWER_ITEM"))
{
const wchar_t* path = (const wchar_t*)payload->Data;
std::filesystem::path texturePath = std::filesystem::path(g_AssetPath) / path;
component.Texture = Texture2D::Create(texturePath.string());
}
ImGui::EndDragDropTarget();
}
ImGui::DragFloat("Tiling Color", &component.TilingFactor, 0.1f, 0.0f, 100.f);
});
}