@dolami-inc/react-native-expo-unity 0.4.0 → 0.4.2

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.
@@ -44,11 +44,12 @@ class UnityBridge private constructor() : IUnityPlayerLifecycleEvents, NativeCal
44
44
  get() = unityPlayer != null
45
45
 
46
46
  /**
47
- * Returns the UnityPlayer view for embedding.
48
- * Unity 6+ made UnityPlayer abstract; use getView() to get the renderable view.
47
+ * Returns the UnityPlayer's FrameLayout container for embedding.
48
+ * Unity 6+ made UnityPlayer abstract; getFrameLayout() returns the full
49
+ * container with the rendering surface inside it.
49
50
  */
50
51
  val unityPlayerView: View?
51
- get() = unityPlayer?.view
52
+ get() = unityPlayer?.frameLayout
52
53
 
53
54
  fun initialize(activity: Activity) {
54
55
  if (isInitialized) return
@@ -58,6 +59,11 @@ class UnityBridge private constructor() : IUnityPlayerLifecycleEvents, NativeCal
58
59
  val player = UnityPlayerForActivityOrService(activity, this)
59
60
  unityPlayer = player
60
61
 
62
+ // Start Unity rendering — without these calls the player
63
+ // stays in a paused/unfocused state and shows a blank screen.
64
+ player.resume()
65
+ player.windowFocusChanged(true)
66
+
61
67
  NativeCallProxy.registerListener(this)
62
68
 
63
69
  Log.i(TAG, "Unity initialized")
package/app.plugin.js CHANGED
@@ -4,6 +4,7 @@ const {
4
4
  withProjectBuildGradle,
5
5
  withAppBuildGradle,
6
6
  withGradleProperties,
7
+ withDangerousMod,
7
8
  } = require('@expo/config-plugins');
8
9
  const path = require('path');
9
10
  const fs = require('fs');
@@ -41,6 +42,7 @@ function parsePropertiesFile(filePath) {
41
42
  * - Includes the :unityLibrary Gradle module and .androidlib subprojects in settings.gradle
42
43
  * - Copies Unity gradle properties (unity.*, unityStreamingAssets) to host gradle.properties
43
44
  * - Adds flatDir repos for Unity's .aar/.jar libs in root build.gradle
45
+ * - Strips LAUNCHER intent from Unity's AndroidManifest (prevents duplicate app icon)
44
46
  * - Adds the unityLibrary dependency and NDK abiFilters in app/build.gradle
45
47
  *
46
48
  * @param {object} config - Expo config
@@ -144,6 +146,49 @@ const withExpoUnity = (config, options = {}) => {
144
146
  return config;
145
147
  });
146
148
 
149
+ // -- Android: Strip LAUNCHER intent from Unity's AndroidManifest --
150
+ // Unity exports include a LAUNCHER intent filter on UnityPlayerGameActivity,
151
+ // which creates a duplicate app icon. Since Unity is embedded (not standalone),
152
+ // we remove it so only the host app's launcher entry exists.
153
+ config = withDangerousMod(config, [
154
+ 'android',
155
+ (config) => {
156
+ const projectRoot = config.modRequest.projectRoot;
157
+ const androidUnityPath =
158
+ options.androidUnityPath ||
159
+ process.env.EXPO_UNITY_ANDROID_PATH ||
160
+ path.join(projectRoot, 'unity', 'builds', 'android');
161
+
162
+ const manifestPath = path.join(
163
+ androidUnityPath,
164
+ 'unityLibrary',
165
+ 'src',
166
+ 'main',
167
+ 'AndroidManifest.xml'
168
+ );
169
+
170
+ if (fs.existsSync(manifestPath)) {
171
+ let manifest = fs.readFileSync(manifestPath, 'utf8');
172
+
173
+ // Remove the entire <intent-filter> block containing LAUNCHER
174
+ const launcherRegex =
175
+ /\s*<intent-filter>\s*<category[^>]*LAUNCHER[^>]*\/>\s*<action[^>]*MAIN[^>]*\/>\s*<\/intent-filter>/g;
176
+ const altLauncherRegex =
177
+ /\s*<intent-filter>\s*<action[^>]*MAIN[^>]*\/>\s*<category[^>]*LAUNCHER[^>]*\/>\s*<\/intent-filter>/g;
178
+
179
+ const patched = manifest
180
+ .replace(launcherRegex, '')
181
+ .replace(altLauncherRegex, '');
182
+
183
+ if (patched !== manifest) {
184
+ fs.writeFileSync(manifestPath, patched, 'utf8');
185
+ }
186
+ }
187
+
188
+ return config;
189
+ },
190
+ ]);
191
+
147
192
  // -- Android: gradle.properties (copy Unity properties to host project) --
148
193
  // Unity's build.gradle references properties like `unityStreamingAssets` and
149
194
  // `unity.*` that are defined in the Unity export's gradle.properties. When the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolami-inc/react-native-expo-unity",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Unity as a Library (UaaL) bridge for React Native / Expo",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",