123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using UnityEngine;
- namespace EZXR.Glass.Projection
- {
- public class ProjectionAPI
- {
- static AndroidJavaObject instance;
- static AndroidJavaObject Instance
- {
- get
- {
- if (instance == null)
- {
- instance = new AndroidJavaObject("com.ezxr.glass.projectionlib.API");
- }
- return instance;
- }
- }
-
-
-
-
-
- public static void Init(Action<int> callBack_OnStart, Action callBack_OnStop)
- {
- #if UNITY_EDITOR
- #else
- ProjectionCallback projectionCallback = new ProjectionCallback(callBack_OnStart, callBack_OnStop);
- AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
- AndroidJavaObject unityActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
- Instance.Call("init", unityActivity, projectionCallback);
- #endif
- }
-
- public static void DeInit()
- {
- #if UNITY_EDITOR
- #else
- Instance.Call("deInit");
- #endif
- }
-
-
-
-
- public static void Start(int textureId, int width, int height)
- {
- #if UNITY_EDITOR
- #else
- Instance.Call("start", textureId, width, height);
- #endif
- }
-
- public static void Stop()
- {
- #if UNITY_EDITOR
- #else
- Instance.Call("stop");
- #endif
- }
-
-
-
-
- public static void NotifyNewFrame(long timestamp)
- {
- #if UNITY_EDITOR
- #else
- Instance.Call("notifyNewFrame", timestamp);
- #endif
- }
- }
- }
|