feat: expand editor scripting asset and viewport flow
This commit is contained in:
@@ -7,8 +7,11 @@
|
||||
|
||||
#include <XCEngine/Components/CameraComponent.h>
|
||||
#include <XCEngine/Components/LightComponent.h>
|
||||
#include <XCEngine/Components/MeshFilterComponent.h>
|
||||
#include <XCEngine/Components/MeshRendererComponent.h>
|
||||
#include <XCEngine/Core/Math/Quaternion.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Resources/BuiltinResources.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -80,6 +83,31 @@ inline ::XCEngine::Components::GameObject* CreateLightEntity(
|
||||
});
|
||||
}
|
||||
|
||||
inline ::XCEngine::Components::GameObject* CreatePrimitiveEntity(
|
||||
IEditorContext& context,
|
||||
::XCEngine::Resources::BuiltinPrimitiveType primitiveType,
|
||||
::XCEngine::Components::GameObject* parent = nullptr) {
|
||||
const char* primitiveName = ::XCEngine::Resources::GetBuiltinPrimitiveDisplayName(primitiveType);
|
||||
return CreateEntity(
|
||||
context,
|
||||
std::string("Create ") + primitiveName,
|
||||
primitiveName,
|
||||
parent,
|
||||
[primitiveType](::XCEngine::Components::GameObject& entity, ISceneManager&) {
|
||||
auto* meshFilter = entity.GetComponent<::XCEngine::Components::MeshFilterComponent>();
|
||||
if (meshFilter == nullptr) {
|
||||
meshFilter = entity.AddComponent<::XCEngine::Components::MeshFilterComponent>();
|
||||
}
|
||||
meshFilter->SetMeshPath(::XCEngine::Resources::GetBuiltinPrimitiveMeshPath(primitiveType).CStr());
|
||||
|
||||
auto* meshRenderer = entity.GetComponent<::XCEngine::Components::MeshRendererComponent>();
|
||||
if (meshRenderer == nullptr) {
|
||||
meshRenderer = entity.AddComponent<::XCEngine::Components::MeshRendererComponent>();
|
||||
}
|
||||
meshRenderer->SetMaterialPath(0, ::XCEngine::Resources::GetBuiltinDefaultPrimitiveMaterialPath().CStr());
|
||||
});
|
||||
}
|
||||
|
||||
inline bool RenameEntity(
|
||||
IEditorContext& context,
|
||||
::XCEngine::Components::GameObject::ID entityId,
|
||||
|
||||
Reference in New Issue
Block a user