fix(editor): create scene context objects at root
This commit is contained in:
parent
097e1c9475
commit
453abfbf46
@ -931,7 +931,7 @@ void MetaCoreConfigureChineseFont() {
|
||||
void MetaCoreDrawSceneViewContextMenu(MetaCoreEditorContext& editorContext, MetaCoreId contextObjectId) {
|
||||
const MetaCoreGameObject contextObject = editorContext.GetScene().FindGameObject(contextObjectId);
|
||||
const bool hasContextObject = static_cast<bool>(contextObject);
|
||||
const std::optional<MetaCoreId> forcedParentId = hasContextObject ? std::optional<MetaCoreId>(contextObjectId) : std::nullopt;
|
||||
const std::optional<MetaCoreId> forcedParentId = hasContextObject ? std::optional<MetaCoreId>(contextObjectId) : std::optional<MetaCoreId>(0);
|
||||
|
||||
if (hasContextObject) {
|
||||
ImGui::TextDisabled("Object: %s", contextObject.GetName().c_str());
|
||||
|
||||
@ -356,6 +356,18 @@ void MetaCoreTestHierarchyEditingCommandsDirtyAndUndo() {
|
||||
MetaCoreExpect(scenePersistenceService->SaveCurrentScene(editorContext), "Hierarchy command scene should save after create");
|
||||
MetaCoreExpect(!scenePersistenceService->IsSceneDirty(), "Hierarchy command scene should be clean after create save");
|
||||
|
||||
editorContext.SelectOnly(*createdId);
|
||||
const auto forcedRootId = sceneEditingService->CreateGameObject(
|
||||
editorContext,
|
||||
"ForcedRootObject",
|
||||
false,
|
||||
std::optional<MetaCore::MetaCoreId>{0}
|
||||
);
|
||||
MetaCoreExpect(forcedRootId.has_value(), "CreateGameObject with forced root parent should create an object");
|
||||
MetaCoreExpect(scene.FindGameObject(*forcedRootId).GetParentId() == 0, "CreateGameObject forced root parent should ignore active selection");
|
||||
MetaCoreExpect(scenePersistenceService->SaveCurrentScene(editorContext), "Hierarchy command scene should save after forced root create");
|
||||
MetaCoreExpect(!scenePersistenceService->IsSceneDirty(), "Hierarchy command scene should be clean after forced root create save");
|
||||
|
||||
MetaCoreExpect(sceneEditingService->RenameGameObject(editorContext, *createdId, "HierarchyObjectRenamed"), "RenameGameObject command should rename object");
|
||||
MetaCoreExpect(scenePersistenceService->IsSceneDirty(), "RenameGameObject command should mark scene dirty");
|
||||
MetaCoreExpect(editorContext.UndoCommand(), "Undo RenameGameObject should succeed");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user