Encapsulates a native UObject pointer and takes care of properly disposing of it.
Inheritance: System.Runtime.InteropServices.SafeHandle
示例#1
0
 public TestComponent(long instanceID, UObjectHandle nativeComponent)
     : base(instanceID, nativeComponent)
 {
 }
示例#2
0
 public UKlawrScriptComponent(long instanceID, UObjectHandle nativeComponent)
     : base(nativeComponent)
 {
     _instanceID = instanceID;
 }
示例#3
0
文件: Object.cs 项目: FashGek/klawr
 /// <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;
 }
示例#4
0
 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;
 }
示例#5
0
 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;
 }
示例#6
0
 public static void SetObjectAt(ArrayHandle arrayHandle, Int32 index, UObjectHandle item)
 {
     _proxy.SetObjectAt(arrayHandle, index, item);
 }
示例#7
0
 public static Int32 FindObject(ArrayHandle arrayHandle, UObjectHandle item)
 {
     return _proxy.FindObject(arrayHandle, item);
 }
示例#8
0
 public TestActor(long instanceID, UObjectHandle nativeObject) : base(instanceID, nativeObject)
 {
     Console.WriteLine("TestActor()");
 }
示例#9
0
 public static bool IsClassChildOf(UObjectHandle derivedClass, UObjectHandle baseClass)
 {
     return _proxy.IsClassChildOf(derivedClass, baseClass);
 }
示例#10
0
 public static string GetClassName(UObjectHandle nativeClass)
 {
     return _proxy.GetClassName(nativeClass);
 }