@dolami-inc/react-native-expo-unity 0.3.2 → 0.3.3
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.
- package/app.plugin.js +21 -7
- package/package.json +1 -1
package/app.plugin.js
CHANGED
|
@@ -16,7 +16,7 @@ const fs = require('fs');
|
|
|
16
16
|
* bundle at build time (device builds only)
|
|
17
17
|
*
|
|
18
18
|
* Android:
|
|
19
|
-
* - Includes the :unityLibrary Gradle module in settings.gradle
|
|
19
|
+
* - Includes the :unityLibrary Gradle module and .androidlib subprojects in settings.gradle
|
|
20
20
|
* - Adds flatDir repos for Unity's .aar/.jar libs in root build.gradle
|
|
21
21
|
* - Adds the unityLibrary dependency and NDK abiFilters in app/build.gradle
|
|
22
22
|
*
|
|
@@ -84,7 +84,7 @@ const withExpoUnity = (config, options = {}) => {
|
|
|
84
84
|
return config;
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
// -- Android: settings.gradle (include :unityLibrary module) --
|
|
87
|
+
// -- Android: settings.gradle (include :unityLibrary module + subprojects) --
|
|
88
88
|
config = withSettingsGradle(config, (config) => {
|
|
89
89
|
const projectRoot = config.modRequest.projectRoot;
|
|
90
90
|
const androidUnityPath =
|
|
@@ -92,18 +92,32 @@ const withExpoUnity = (config, options = {}) => {
|
|
|
92
92
|
process.env.EXPO_UNITY_ANDROID_PATH ||
|
|
93
93
|
path.join(projectRoot, 'unity', 'builds', 'android');
|
|
94
94
|
|
|
95
|
-
const
|
|
95
|
+
const unityLibDir = path.join(androidUnityPath, 'unityLibrary');
|
|
96
96
|
|
|
97
97
|
// Include :unityLibrary module
|
|
98
98
|
const includeSnippet = `include ':unityLibrary'`;
|
|
99
|
-
const projectSnippet = `project(':unityLibrary').projectDir = new File('${
|
|
99
|
+
const projectSnippet = `project(':unityLibrary').projectDir = new File('${unityLibDir}')`;
|
|
100
100
|
|
|
101
|
-
if (!contents.includes(includeSnippet)) {
|
|
102
|
-
config.modResults.contents
|
|
103
|
-
contents +
|
|
101
|
+
if (!config.modResults.contents.includes(includeSnippet)) {
|
|
102
|
+
config.modResults.contents +=
|
|
104
103
|
`\n// Unity as a Library\n${includeSnippet}\n${projectSnippet}\n`;
|
|
105
104
|
}
|
|
106
105
|
|
|
106
|
+
// Auto-discover .androidlib subprojects (e.g. xrmanifest.androidlib)
|
|
107
|
+
if (fs.existsSync(unityLibDir)) {
|
|
108
|
+
const subprojects = fs.readdirSync(unityLibDir).filter((name) =>
|
|
109
|
+
name.endsWith('.androidlib') &&
|
|
110
|
+
fs.existsSync(path.join(unityLibDir, name, 'build.gradle'))
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
for (const sub of subprojects) {
|
|
114
|
+
const subInclude = `include ':unityLibrary:${sub}'`;
|
|
115
|
+
if (!config.modResults.contents.includes(subInclude)) {
|
|
116
|
+
config.modResults.contents += `${subInclude}\n`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
107
121
|
return config;
|
|
108
122
|
});
|
|
109
123
|
|