添加ui_editor编辑器模块初始代码
This commit is contained in:
38
ui_editor/src/Managers/SelectionManager.h
Normal file
38
ui_editor/src/Managers/SelectionManager.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/GameObject.h"
|
||||
#include "Core/Event.h"
|
||||
#include <unordered_set>
|
||||
|
||||
namespace UI {
|
||||
|
||||
class SelectionManager {
|
||||
public:
|
||||
static SelectionManager& Get() {
|
||||
static SelectionManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
EntityID GetSelectedEntity() const { return m_selectedEntity; }
|
||||
|
||||
void SetSelectedEntity(EntityID id) {
|
||||
m_selectedEntity = id;
|
||||
OnSelectionChanged.Invoke(id);
|
||||
}
|
||||
|
||||
void ClearSelection() {
|
||||
SetSelectedEntity(INVALID_ENTITY);
|
||||
}
|
||||
|
||||
bool IsSelected(EntityID id) const {
|
||||
return m_selectedEntity == id;
|
||||
}
|
||||
|
||||
Event<EntityID> OnSelectionChanged;
|
||||
|
||||
private:
|
||||
SelectionManager() = default;
|
||||
EntityID m_selectedEntity = INVALID_ENTITY;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user