feat(scripting): add mono csharp runtime foundation
This commit is contained in:
55
managed/XCEngine.ScriptCore/GameObject.cs
Normal file
55
managed/XCEngine.ScriptCore/GameObject.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public sealed class GameObject
|
||||
{
|
||||
private readonly ulong m_uuid;
|
||||
|
||||
internal GameObject(ulong uuid)
|
||||
{
|
||||
m_uuid = uuid;
|
||||
}
|
||||
|
||||
public ulong UUID => m_uuid;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => InternalCalls.GameObject_GetName(UUID) ?? string.Empty;
|
||||
set => InternalCalls.GameObject_SetName(UUID, value ?? string.Empty);
|
||||
}
|
||||
|
||||
public string name
|
||||
{
|
||||
get => Name;
|
||||
set => Name = value;
|
||||
}
|
||||
|
||||
public bool activeSelf => InternalCalls.GameObject_GetActiveSelf(UUID);
|
||||
|
||||
public bool activeInHierarchy => InternalCalls.GameObject_GetActiveInHierarchy(UUID);
|
||||
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
InternalCalls.GameObject_SetActive(UUID, value);
|
||||
}
|
||||
|
||||
public Transform Transform => GetComponent<Transform>();
|
||||
public Transform transform => Transform;
|
||||
|
||||
public bool HasComponent<T>() where T : Component
|
||||
{
|
||||
return InternalCalls.GameObject_HasComponent(UUID, typeof(T));
|
||||
}
|
||||
|
||||
public T GetComponent<T>() where T : Component
|
||||
{
|
||||
ulong componentOwnerUUID = InternalCalls.GameObject_GetComponent(UUID, typeof(T));
|
||||
return Component.Create<T>(componentOwnerUUID);
|
||||
}
|
||||
|
||||
public bool TryGetComponent<T>(out T component) where T : Component
|
||||
{
|
||||
component = GetComponent<T>();
|
||||
return component != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user