feat(scripting): support managed script component api

This commit is contained in:
2026-03-28 00:43:13 +08:00
parent 6bde199393
commit e522bad582
8 changed files with 349 additions and 37 deletions

View File

@@ -64,14 +64,12 @@ namespace XCEngine
public T GetComponent<T>() where T : Component
{
ulong componentOwnerUUID = InternalCalls.GameObject_GetComponent(UUID, typeof(T));
return Component.Create<T>(componentOwnerUUID);
return InternalCalls.GameObject_GetComponent(UUID, typeof(T)) as T;
}
public T AddComponent<T>() where T : Component
{
ulong componentOwnerUUID = InternalCalls.GameObject_AddComponent(UUID, typeof(T));
return Component.Create<T>(componentOwnerUUID);
return InternalCalls.GameObject_AddComponent(UUID, typeof(T)) as T;
}
public bool TryGetComponent<T>(out T component) where T : Component