본문 바로가기
모바일/유니티

유니티 | Unity Interface 개발

by KISCH 2020. 3. 11.
반응형


유니티인터페이스




Bridge (Unity Interface) 개발


MonoBehavior 상속, GameObject(DontDestroyOnLoad)에 Attach

Bridge (C#)

// 웹뷰가 필요한 곳에서 이 메서드 호출

  

public void OpenWebView(string url) {

openNativeWebView(url);

}

#if UNITY_IPHONE

        // iOS Plugin에 구현 되어야 할 method, extern "C"

        [DllImport ("__Internal")] public static extern void openNativeWebView(string aParam);


#elif UNITY_ANDROID

        public AndroidJavaClass  mPlayer;

        public AndroidJavaObject mCurrentActivity;

        public void openNativeWebView(string aParam)

        {

                if (mPlayer == null && mCurrentActivity == null)

   {

                        mPlayer          = new AndroidJavaClass("com.unity3d.player.UnityPlayer");


                        mCurrentActivity = mPlayer.GetStatic<AndroidJavaObject>("currentActivity"); 

                }

                mCurrentActivity.Call("openNativeWebView", new string[]{aParam});

        }

#else

        public void openNativeWebView (string aParam) {}

#endif 


반응형

댓글