Align Unity-style object and hierarchy scripting APIs
This commit is contained in:
@@ -3,7 +3,7 @@ using System.Reflection;
|
||||
|
||||
namespace XCEngine
|
||||
{
|
||||
public abstract class Component
|
||||
public abstract class Component : Object
|
||||
{
|
||||
internal ulong m_gameObjectUUID;
|
||||
|
||||
@@ -34,6 +34,16 @@ namespace XCEngine
|
||||
return GameObject.GetComponent<T>();
|
||||
}
|
||||
|
||||
public T GetComponentInChildren<T>() where T : Component
|
||||
{
|
||||
return GameObject.GetComponentInChildren<T>();
|
||||
}
|
||||
|
||||
public T GetComponentInParent<T>() where T : Component
|
||||
{
|
||||
return GameObject.GetComponentInParent<T>();
|
||||
}
|
||||
|
||||
public T AddComponent<T>() where T : Component
|
||||
{
|
||||
return GameObject.AddComponent<T>();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public sealed class GameObject
|
||||
public sealed class GameObject : Object
|
||||
{
|
||||
private readonly ulong m_uuid;
|
||||
|
||||
@@ -67,6 +67,16 @@ namespace XCEngine
|
||||
return InternalCalls.GameObject_GetComponent(UUID, typeof(T)) as T;
|
||||
}
|
||||
|
||||
public T GetComponentInChildren<T>() where T : Component
|
||||
{
|
||||
return InternalCalls.GameObject_GetComponentInChildren(UUID, typeof(T)) as T;
|
||||
}
|
||||
|
||||
public T GetComponentInParent<T>() where T : Component
|
||||
{
|
||||
return InternalCalls.GameObject_GetComponentInParent(UUID, typeof(T)) as T;
|
||||
}
|
||||
|
||||
public T AddComponent<T>() where T : Component
|
||||
{
|
||||
return InternalCalls.GameObject_AddComponent(UUID, typeof(T)) as T;
|
||||
|
||||
@@ -86,6 +86,12 @@ namespace XCEngine
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern Component GameObject_GetComponent(ulong gameObjectUUID, Type componentType);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern Component GameObject_GetComponentInChildren(ulong gameObjectUUID, Type componentType);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern Component GameObject_GetComponentInParent(ulong gameObjectUUID, Type componentType);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern Component GameObject_AddComponent(ulong gameObjectUUID, Type componentType);
|
||||
|
||||
@@ -98,6 +104,9 @@ namespace XCEngine
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void GameObject_Destroy(ulong gameObjectUUID);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern void Object_Destroy(global::XCEngine.Object obj);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool Behaviour_GetEnabled(ulong scriptComponentUUID);
|
||||
|
||||
|
||||
19
managed/XCEngine.ScriptCore/Object.cs
Normal file
19
managed/XCEngine.ScriptCore/Object.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace XCEngine
|
||||
{
|
||||
public abstract class Object
|
||||
{
|
||||
protected Object()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Destroy(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InternalCalls.Object_Destroy(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user