MaxstARSDK  3.5.0
AndroidEngine.cs
1 /*==============================================================================
2 Copyright 2017 Maxst, Inc. All Rights Reserved.
3 ==============================================================================*/
4 
5 using System;
6 using UnityEngine;
7 using System.Collections;
8 
9 namespace maxstAR
10 {
11  internal class AndroidEngine : IDisposable
12  {
13  private AndroidJavaObject currentActivity;
14  private AndroidJavaClass maxstARClass;
15 
16  public AndroidEngine(string appKey)
17  {
18  if (currentActivity == null || maxstARClass == null)
19  {
20  AndroidJavaClass javaUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
21  currentActivity = javaUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
22  if (currentActivity != null)
23  {
24  maxstARClass = new AndroidJavaClass("com.maxst.ar.MaxstARInitializer");
25  maxstARClass.CallStatic("init", currentActivity, appKey);
26 
27  //if (AbstractConfigurationScriptableObject.GetInstance().WearableType ==
28  // WearableCalibration.WearableType.OpticalSeeThrough)
29  //{
30  // WearableDeviceController.Instance.Init(currentActivity);
31  // bool res = maxstARClass.CallStatic<bool>("readActiveCalibrationProfile");
32  // Debug.Log("readActiveCalibrationProfile: " + res.ToString());
33  //}
34  }
35  else
36  {
37  Debug.Log("No Activity");
38  }
39  }
40  }
41 
42  public void Dispose()
43  {
44  if (currentActivity != null && maxstARClass != null)
45  {
46  maxstARClass.CallStatic("deinit");
47  currentActivity.Dispose();
48  currentActivity = null;
49 
50  maxstARClass.Dispose();
51  maxstARClass = null;
52 
53  //if (AbstractConfigurationScriptableObject.GetInstance().WearableType ==
54  // WearableCalibration.WearableType.OpticalSeeThrough)
55  //{
56  // WearableDeviceController.Instance.Deinit();
57  //}
58  }
59  }
60  }
61 }