t1 / TFDContents / Assets / Standard Assets / NativeWrapper.cs @ 9
이력 | 보기 | 이력해설 | 다운로드 (722 Bytes)
1 |
#if !(UNITY_WSA_10_0 && NETFX_CORE) |
---|---|
2 |
using System; |
3 |
using System.Collections.Generic; |
4 |
using System.Runtime.InteropServices; |
5 |
using System.Linq; |
6 |
|
7 |
namespace Helper |
8 |
{ |
9 |
public static class NativeWrapper |
10 |
{ |
11 |
public static System.IntPtr GetNativePtr(Object obj) |
12 |
{ |
13 |
if(obj == null) |
14 |
{ |
15 |
return System.IntPtr.Zero; |
16 |
} |
17 |
|
18 |
var nativeWrapperIface = obj as INativeWrapper; |
19 |
if(nativeWrapperIface != null) |
20 |
{ |
21 |
return nativeWrapperIface.nativePtr; |
22 |
} |
23 |
else |
24 |
{ |
25 |
throw new ArgumentException("Object must wrap native type"); |
26 |
} |
27 |
} |
28 |
} |
29 |
} |
30 |
#endif |