drag entity from entity list and drop it in property grid
This commit is contained in:
parent
2a1b6fe536
commit
f29e3d1391
3 changed files with 13 additions and 3 deletions
|
@ -524,8 +524,7 @@ public:
|
|||
if (!m_entity_to_prefab.empty()) serializer.write(m_entity_to_prefab.begin(), m_entity_to_prefab.byte_size());
|
||||
|
||||
serializer.write((u32)m_resources.size());
|
||||
for (const PrefabVersion& prefab : m_resources)
|
||||
{
|
||||
for (const PrefabVersion& prefab : m_resources) {
|
||||
serializer.writeString(prefab.resource->getPath().c_str());
|
||||
serializer.write(prefab.content_hash);
|
||||
}
|
||||
|
|
|
@ -262,6 +262,13 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
|
|||
{
|
||||
ImGui::OpenPopup(prop.name);
|
||||
}
|
||||
if (ImGui::BeginDragDropTarget()) {
|
||||
if (auto* payload = ImGui::AcceptDragDropPayload("entity")) {
|
||||
EntityRef dropped_entity = *(EntityRef*)payload->Data;
|
||||
m_editor.setProperty(m_cmp_type, m_index, prop.name, m_entities, dropped_entity);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%s", prop.name);
|
||||
|
|
|
@ -1652,7 +1652,6 @@ struct StudioAppImpl final : StudioApp
|
|||
if (!has_child) flags = ImGuiTreeNodeFlags_Leaf;
|
||||
if (selected) flags |= ImGuiTreeNodeFlags_Selected;
|
||||
bool node_open = ImGui::TreeNodeEx(buffer, flags);
|
||||
if (ImGui::IsItemClicked(0)) m_editor->selectEntities(&entity, 1, true);
|
||||
if (ImGui::IsMouseReleased(1) && ImGui::IsItemHovered()) ImGui::OpenPopup("entity_context_menu");
|
||||
if (ImGui::BeginPopup("entity_context_menu"))
|
||||
{
|
||||
|
@ -1674,6 +1673,11 @@ struct StudioAppImpl final : StudioApp
|
|||
ImGui::SetDragDropPayload("entity", &entity, sizeof(entity));
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
else {
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) {
|
||||
m_editor->selectEntities(&entity, 1, true);
|
||||
}
|
||||
}
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
if (auto* payload = ImGui::AcceptDragDropPayload("entity"))
|
||||
|
|
Loading…
Reference in a new issue