editor: bind inspector and console to live runtime state

This commit is contained in:
2026-04-29 18:07:44 +08:00
parent f74503c2a5
commit a99879065c
14 changed files with 262 additions and 71 deletions

View File

@@ -3,6 +3,7 @@
#include "Inspector/InspectorFieldValueApplier.h"
#include "Inspector/InspectorPresentationModel.h"
#include "Inspector/InspectorSubject.h"
#include "Project/EditorProjectRuntime.h"
#include "Scene/EditorSceneRuntime.h"
#include "Scene/EngineEditorSceneBackend.h"
@@ -331,8 +332,9 @@ TEST(InspectorPresentationModelTests, SceneObjectSubjectBuildsRegisteredComponen
ASSERT_NE(parent, nullptr);
ASSERT_TRUE(runtime.SetSelection(parent->GetID()));
EditorProjectRuntime projectRuntime = {};
const InspectorSubject subject =
BuildInspectorSubject(EditorSession{}, runtime);
BuildInspectorSubject(projectRuntime, runtime);
ASSERT_EQ(subject.kind, InspectorSubjectKind::SceneObject);
const InspectorPresentationModel model =
@@ -407,9 +409,10 @@ TEST(InspectorPresentationModelTests, CameraSkyboxMaterialBuildsAssetField) {
camera->SetSkyboxMaterialPath("Assets/Materials/Skybox.mat");
ASSERT_TRUE(runtime.SetSelection(parent->GetID()));
EditorProjectRuntime projectRuntime = {};
const InspectorPresentationModel model =
BuildInspectorPresentationModel(
BuildInspectorSubject(EditorSession{}, runtime),
BuildInspectorSubject(projectRuntime, runtime),
runtime,
InspectorComponentEditorRegistry::Get());
@@ -441,9 +444,10 @@ TEST(InspectorPresentationModelTests, ScriptComponentBuildsScriptSelectorSection
ASSERT_NE(parent->AddComponent<::XCEngine::Scripting::ScriptComponent>(), nullptr);
ASSERT_TRUE(runtime.SetSelection(parent->GetID()));
EditorProjectRuntime projectRuntime = {};
const InspectorPresentationModel model =
BuildInspectorPresentationModel(
BuildInspectorSubject(EditorSession{}, runtime),
BuildInspectorSubject(projectRuntime, runtime),
runtime,
InspectorComponentEditorRegistry::Get());
@@ -507,7 +511,8 @@ TEST(InspectorPresentationModelTests, ScriptComponentReferenceFieldsSupportActiv
ASSERT_TRUE(runtime.SetSelection(parent->GetID()));
InspectorSubject subject = BuildInspectorSubject(EditorSession{}, runtime);
EditorProjectRuntime projectRuntime = {};
InspectorSubject subject = BuildInspectorSubject(projectRuntime, runtime);
const InspectorPresentationModel model =
BuildInspectorPresentationModel(
subject,
@@ -554,7 +559,7 @@ TEST(InspectorPresentationModelTests, ScriptComponentReferenceFieldsSupportActiv
EXPECT_EQ(runtime.GetSelectedObjectId().value(), child->GetID());
ASSERT_TRUE(runtime.SetSelection(parent->GetID()));
subject = BuildInspectorSubject(EditorSession{}, runtime);
subject = BuildInspectorSubject(projectRuntime, runtime);
const InspectorPresentationModel refreshedModel =
BuildInspectorPresentationModel(
subject,
@@ -612,8 +617,9 @@ TEST(InspectorPresentationModelTests, BoundFieldValueApplierKeepsComponentViewAl
ASSERT_NE(parent, nullptr);
ASSERT_TRUE(runtime.SetSelection(parent->GetID()));
EditorProjectRuntime projectRuntime = {};
const InspectorSubject subject =
BuildInspectorSubject(EditorSession{}, runtime);
BuildInspectorSubject(projectRuntime, runtime);
ASSERT_EQ(subject.kind, InspectorSubjectKind::SceneObject);
const InspectorPresentationModel model =