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

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.
Files changed (2) hide show
  1. package/app.plugin.js +45 -0
  2. package/package.json +1 -1
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.1",
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",