feat(scripting): add mesh component script wrappers

This commit is contained in:
2026-03-27 14:52:00 +08:00
parent 2b0df52446
commit bea849646f
12 changed files with 448 additions and 8 deletions

View File

@@ -66,6 +66,19 @@ TEST(MeshFilterComponent_Test, SerializeAndDeserializePreservesPath) {
delete mesh;
}
TEST(MeshFilterComponent_Test, SetMeshPathPreservesPathWithoutLoadedResource) {
MeshFilterComponent component;
component.SetMeshPath("Meshes/runtime.mesh");
EXPECT_EQ(component.GetMeshPath(), "Meshes/runtime.mesh");
EXPECT_EQ(component.GetMesh(), nullptr);
component.SetMeshPath("");
EXPECT_EQ(component.GetMeshPath(), "");
EXPECT_EQ(component.GetMesh(), nullptr);
}
TEST(MeshRendererComponent_Test, SetMaterialsKeepsSlotsAndFlags) {
GameObject gameObject("RendererHolder");
auto* component = gameObject.AddComponent<MeshRendererComponent>();
@@ -122,4 +135,20 @@ TEST(MeshRendererComponent_Test, SerializeAndDeserializePreservesMaterialPathsAn
delete material1;
}
TEST(MeshRendererComponent_Test, SetMaterialPathPreservesPathWithoutLoadedResource) {
MeshRendererComponent component;
component.SetMaterialPath(1, "Materials/runtime.mat");
ASSERT_EQ(component.GetMaterialCount(), 2u);
EXPECT_EQ(component.GetMaterial(0), nullptr);
EXPECT_EQ(component.GetMaterial(1), nullptr);
EXPECT_EQ(component.GetMaterialPath(0), "");
EXPECT_EQ(component.GetMaterialPath(1), "Materials/runtime.mat");
component.SetMaterialPath(1, "");
EXPECT_EQ(component.GetMaterialPath(1), "");
EXPECT_EQ(component.GetMaterial(1), nullptr);
}
} // namespace