1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using UnityEngine;
- public class UnityCallAndroid : MonoBehaviour
- {
- private AndroidJavaObject RTKManager;
- void Start()
- {
- Func();
- }
- public void Func()
- {
- AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
- AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
- try
- {
- RTKManager = new AndroidJavaObject("com.bxzzbdh.rtktest.RTK", jo);
- Debug.Log("RTK Has Been Called");
- }
- catch (Exception e)
- {
- Debug.LogError($"Func Expection{e}");
- }
- StartRtk();
- }
-
- public void StartRtk()
- {
- try
- {
- RTKManager.Call("StartRTK");
- }
- catch (Exception e)
- {
- Debug.LogError($"StartRTK Expection{e}");
- }
- }
- private void OnApplicationQuit()
- {
- RTKManager.Call("StopRTK");
- }
- }
|