Added new Prefab C# type
This commit is contained in:
@@ -206,6 +206,23 @@ namespace Nuake {
|
||||
return entity.IsValid();
|
||||
}
|
||||
|
||||
int PrefabInstance(Coral::String path, Vector3 position, float qx, float qy, float qz, float qw)
|
||||
{
|
||||
if (!FileSystem::FileExists(path))
|
||||
{
|
||||
Logger::Log("Prefab path doesn't exist", ".net", CRITICAL);
|
||||
}
|
||||
|
||||
const auto& prefab = Prefab::New(path);
|
||||
|
||||
Entity root = prefab->Root;
|
||||
TransformComponent& transformComponent = root.GetComponent<TransformComponent>();
|
||||
transformComponent.SetLocalPosition(position);
|
||||
transformComponent.SetLocalRotation(Quat(qw, qx, qy, qz));
|
||||
|
||||
return root.GetHandle();
|
||||
}
|
||||
|
||||
void TransformSetPosition(int entityId, float x, float y, float z)
|
||||
{
|
||||
Entity entity = { (entt::entity)(entityId), Engine::GetCurrentScene().get() };
|
||||
@@ -369,6 +386,9 @@ namespace Nuake {
|
||||
RegisterMethod("Entity.EntitySetNameIcall", &EntitySetName);
|
||||
RegisterMethod("Entity.EntityIsValidIcall", &EntityIsValid);
|
||||
|
||||
// Prefab
|
||||
RegisterMethod("Prefab.PrefabInstanceIcall", &PrefabInstance);
|
||||
|
||||
// Scene
|
||||
RegisterMethod("Scene.GetEntityIcall", &GetEntity);
|
||||
RegisterMethod("Scene.GetEntityScriptFromNameIcall", &GetEntityScriptFromName);
|
||||
|
||||
Reference in New Issue
Block a user