@dolami-inc/react-native-expo-unity 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,7 @@ import android.util.Log
|
|
|
5
5
|
import android.view.ViewGroup
|
|
6
6
|
import android.widget.FrameLayout
|
|
7
7
|
import expo.modules.kotlin.AppContext
|
|
8
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
8
9
|
import expo.modules.kotlin.views.ExpoView
|
|
9
10
|
|
|
10
11
|
class ExpoUnityView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
@@ -8,6 +8,7 @@ import android.view.View
|
|
|
8
8
|
import com.expounity.bridge.NativeCallProxy
|
|
9
9
|
import com.unity3d.player.IUnityPlayerLifecycleEvents
|
|
10
10
|
import com.unity3d.player.UnityPlayer
|
|
11
|
+
import com.unity3d.player.UnityPlayerForActivityOrService
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Singleton managing the UnityPlayer lifecycle.
|
|
@@ -43,17 +44,18 @@ class UnityBridge private constructor() : IUnityPlayerLifecycleEvents, NativeCal
|
|
|
43
44
|
get() = unityPlayer != null
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
|
-
* Returns the UnityPlayer view for embedding.
|
|
47
|
+
* Returns the UnityPlayer view for embedding.
|
|
48
|
+
* Unity 6+ made UnityPlayer abstract; use getView() to get the renderable view.
|
|
47
49
|
*/
|
|
48
50
|
val unityPlayerView: View?
|
|
49
|
-
get() = unityPlayer
|
|
51
|
+
get() = unityPlayer?.view
|
|
50
52
|
|
|
51
53
|
fun initialize(activity: Activity) {
|
|
52
54
|
if (isInitialized) return
|
|
53
55
|
|
|
54
56
|
val runInit = Runnable {
|
|
55
57
|
try {
|
|
56
|
-
val player =
|
|
58
|
+
val player = UnityPlayerForActivityOrService(activity, this)
|
|
57
59
|
unityPlayer = player
|
|
58
60
|
|
|
59
61
|
NativeCallProxy.registerListener(this)
|