BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / Platform / Scripts / WindowsPlatform.cs

WindowsPlatform.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
WindowsPlatform.cs 1.3 KiB Download Raw
1namespace Oculus.Platform
2{
3 using UnityEngine;
4 using System;
5 using System.Collections;
6 using System.Runtime.InteropServices;
7
8 public class WindowsPlatform
9 {
10 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
11 public delegate void UnityLogDelegate(IntPtr tag, IntPtr msg);
12
13 void CPPLogCallback(IntPtr tag, IntPtr message)
14 {
15 Debug.Log(string.Format("{0}: {1}", Marshal.PtrToStringAnsi(tag), Marshal.PtrToStringAnsi(message)));
16 }
17
18 IntPtr getCallbackPointer()
19 {
20 //UnityLogDelegate callback_delegate = new UnityLogDelegate(CPPLogCallback);
21 //IntPtr intptr_delegate = Marshal.GetFunctionPointerForDelegate(callback_delegate);
22 return IntPtr.Zero;
23 }
24
25 public bool Initialize(string appId)
26 {
27 if(String.IsNullOrEmpty(appId))
28 {
29 throw new UnityException("AppID must not be null or empty");
30 }
31
32 CAPI.ovr_UnityInitWrapperWindows(appId, getCallbackPointer());
33 return true;
34 }
35
36 public Request<Models.PlatformInitialize> AsyncInitialize(string appId)
37 {
38 if(String.IsNullOrEmpty(appId))
39 {
40 throw new UnityException("AppID must not be null or empty");
41 }
42
43 return new Request<Models.PlatformInitialize>(CAPI.ovr_UnityInitWrapperWindowsAsynchronous(appId, getCallbackPointer()));
44 }
45 }
46}