public TestComponent(long instanceID, UObjectHandle nativeComponent) : base(instanceID, nativeComponent) { }
public UKlawrScriptComponent(long instanceID, UObjectHandle nativeComponent) : base(nativeComponent) { _instanceID = instanceID; }
/// <summary> /// Construct a new instance from the given native UObject instance. /// </summary> /// <param name="nativeObject">Handle to a native UObject instance.</param> public UObject(UObjectHandle nativeObject) { _nativeObject = nativeObject; }
public bool CreateScriptObject(string className, IntPtr nativeObject, ref ScriptObjectInstanceInfo info) { var objType = FindScriptObjectTypeByName(className); if (objType != null) { var constructor = objType.GetConstructor(new Type[] { typeof(long), typeof(UObjectHandle) }); if (constructor != null) { var instanceID = GenerateScriptObjectID(); // The handle created here is set not to release the native object when the // handle is disposed because that object is actually the owner of the script // object created here, and no additional references are created to owners at // the moment so there is no reference to remove. var objectHandle = new UObjectHandle(nativeObject, false); var obj = (IScriptObject)constructor.Invoke( new object[] { instanceID, objectHandle } ); var objInfo = RegisterScriptObject(obj); info.InstanceID = instanceID; info.BeginPlay = objInfo.BeginPlay; info.Tick = objInfo.Tick; info.Destroy = objInfo.Destroy; return true; } } // TODO: log an error return false; }
public bool CreateScriptComponent( string className, IntPtr nativeComponent, ref ScriptComponentProxy proxy ) { ScriptComponentTypeInfo componentTypeInfo; if (FindScriptComponentTypeByName(className, out componentTypeInfo)) { if (componentTypeInfo.Constructor != null) { var instanceID = GenerateScriptObjectID(); // The handle created here is set not to release the native object when the // handle is disposed because that object is actually the owner of the script // object created here, and no additional references are created to owners at // the moment so there is no reference to remove. var objectHandle = new UObjectHandle(nativeComponent, false); var component = (IDisposable)componentTypeInfo.Constructor.Invoke( new object[] { instanceID, objectHandle } ); // initialize the script component proxy proxy.InstanceID = instanceID; foreach (var methodInfo in componentTypeInfo.Methods) { methodInfo.BindToProxy( ref proxy, Delegate.CreateDelegate( methodInfo.DelegateType, component, methodInfo.Method ) ); } // keep anything that may be called from native code alive RegisterScriptComponent(instanceID, component, proxy); return true; } } // TODO: log an error return false; }
public static void SetObjectAt(ArrayHandle arrayHandle, Int32 index, UObjectHandle item) { _proxy.SetObjectAt(arrayHandle, index, item); }
public static Int32 FindObject(ArrayHandle arrayHandle, UObjectHandle item) { return _proxy.FindObject(arrayHandle, item); }
public TestActor(long instanceID, UObjectHandle nativeObject) : base(instanceID, nativeObject) { Console.WriteLine("TestActor()"); }
public static bool IsClassChildOf(UObjectHandle derivedClass, UObjectHandle baseClass) { return _proxy.IsClassChildOf(derivedClass, baseClass); }
public static string GetClassName(UObjectHandle nativeClass) { return _proxy.GetClassName(nativeClass); }