mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-06 06:09:52 +03:00
work
This commit is contained in:
@@ -301,6 +301,22 @@ namespace Nuake.Net
|
||||
return entity;
|
||||
}
|
||||
|
||||
public T? Instance<T>(Vector3 position = default, Quaternion quat = default) where T : Entity
|
||||
{
|
||||
int handle;
|
||||
unsafe { handle = PrefabInstanceIcall(Path, position, quat.X, quat.Y, quat.Z, quat.W); }
|
||||
|
||||
if (handle == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
T? instance = Scene.GetEntity<T>(handle);
|
||||
instance.OnInit();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static implicit operator bool(Prefab prefab)
|
||||
{
|
||||
if (object.ReferenceEquals(prefab, null))
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Nuake.Net
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static Entity? InstancePrefab(string path, Entity? parent = null)
|
||||
public static T? InstancePrefab<T>(string path, Entity? parent = null) where T : class
|
||||
{
|
||||
int handle;
|
||||
unsafe { handle = InstancePrefabIcall(path); }
|
||||
@@ -73,9 +73,17 @@ namespace Nuake.Net
|
||||
// return entity as T;
|
||||
//}
|
||||
|
||||
Entity entity = new Entity(handle);
|
||||
|
||||
NativeInstance<Entity> nativeInstance;
|
||||
unsafe { nativeInstance = GetEntityScriptFromHandleIcall(handle); }
|
||||
|
||||
return entity;
|
||||
Entity? entity = nativeInstance.Get();
|
||||
if (entity != null && entity is T)
|
||||
{
|
||||
return entity as T;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user