fix build
This commit is contained in:
@@ -48,24 +48,39 @@ Packages/com.omarator.mosissdk/
|
||||
|
||||
## Build Commands
|
||||
|
||||
### Unity Build (Export to Android Studio)
|
||||
### Option 1: Direct APK Build (Recommended)
|
||||
|
||||
Unity exports a Gradle project which is then built in Android Studio:
|
||||
Build directly to APK without exporting:
|
||||
|
||||
1. File > Build Settings
|
||||
2. Switch Platform to Android
|
||||
3. Player Settings > Other Settings:
|
||||
- Scripting Backend: IL2CPP
|
||||
- Target Architectures: ARM64
|
||||
- Graphics APIs: Vulkan, OpenGLES3 (in order of preference)
|
||||
- Minimum API Level: 29
|
||||
4. Check "Export Project"
|
||||
5. Click Export and select output folder (e.g., `D:\Dev\Mosis\Builds\Unity\Android\MosisVR`)
|
||||
```batch
|
||||
"C:\Program Files\Unity\Hub\Editor\6000.3.2f1\Editor\Unity.exe" ^
|
||||
-batchmode -quit -nographics ^
|
||||
-projectPath "D:\Dev\Mosis\MosisVR" ^
|
||||
-executeMethod BuildScript.BuildAndroidDirectCI ^
|
||||
-outputPath "D:\Dev\Mosis\Builds\Unity\Android\MosisVR.apk" ^
|
||||
-logFile "D:\Dev\Mosis\Builds\Unity\build.log"
|
||||
```
|
||||
|
||||
### Build Gradle Project
|
||||
Or from Unity Editor: **Build > Build Android APK (Direct)**
|
||||
|
||||
After exporting from Unity:
|
||||
### Option 2: Export + Gradle Build
|
||||
|
||||
Export a Gradle project for more control over the build process:
|
||||
|
||||
**Step 1: Export from Unity**
|
||||
```batch
|
||||
"C:\Program Files\Unity\Hub\Editor\6000.3.2f1\Editor\Unity.exe" ^
|
||||
-batchmode -quit -nographics ^
|
||||
-projectPath "D:\Dev\Mosis\MosisVR" ^
|
||||
-executeMethod BuildScript.BuildAndroidCI ^
|
||||
-export true ^
|
||||
-outputPath "D:\Dev\Mosis\Builds\Unity\Android\MosisVR" ^
|
||||
-logFile "D:\Dev\Mosis\Builds\Unity\build.log"
|
||||
```
|
||||
|
||||
Or from Unity Editor: **Build > Export Android Project**
|
||||
|
||||
**Step 2: Build with Gradle**
|
||||
```batch
|
||||
cd D:\Dev\Mosis\Builds\Unity\Android\MosisVR
|
||||
gradle assembleRelease
|
||||
@@ -76,20 +91,21 @@ gradle assembleRelease
|
||||
|
||||
Or open in Android Studio and build from there.
|
||||
|
||||
### Command Line Export (Optional)
|
||||
### Unity Editor Manual Build
|
||||
|
||||
```batch
|
||||
"C:\Program Files\Unity\Hub\Editor\6000.3.2f1\Editor\Unity.exe" ^
|
||||
-batchmode -quit -nographics ^
|
||||
-projectPath "D:\Dev\Mosis\MosisVR" ^
|
||||
-executeMethod BuildScript.BuildAndroidCI ^
|
||||
-outputPath "D:\Dev\Mosis\Builds\Unity\Android\MosisVR" ^
|
||||
-logFile "D:\Dev\Mosis\Builds\Unity\build.log"
|
||||
```
|
||||
1. File > Build Settings
|
||||
2. Switch Platform to Android
|
||||
3. Player Settings > Other Settings:
|
||||
- Scripting Backend: IL2CPP
|
||||
- Target Architectures: ARM64
|
||||
- Graphics APIs: Vulkan, OpenGLES3 (in order of preference)
|
||||
- Minimum API Level: 29
|
||||
4. For direct APK: Uncheck "Export Project", click Build
|
||||
5. For export: Check "Export Project", click Export
|
||||
|
||||
### Native Plugin Build (Manual)
|
||||
|
||||
To rebuild the native library manually:
|
||||
The native plugin is built automatically during Unity's build process via CMake. To rebuild manually:
|
||||
|
||||
```batch
|
||||
cd Packages/com.omarator.mosissdk/Plugins/Android/cpp
|
||||
@@ -166,10 +182,11 @@ The native plugin automatically selects the appropriate backend:
|
||||
|--------------|---------|--------|
|
||||
| Vulkan | VulkanTextureBackend | Preferred |
|
||||
| OpenGL ES 3.0 | OpenGLTextureBackend | Fallback |
|
||||
| OpenGL ES 2.0 | OpenGLTextureBackend | Fallback |
|
||||
|
||||
Backend selection happens in `UnityPluginLoad()` based on the active renderer.
|
||||
|
||||
Note: Unity 6 requires OpenGL ES 3.0 minimum. OpenGL ES 2.0 is not supported.
|
||||
|
||||
### Vulkan Import
|
||||
|
||||
When using Vulkan, the plugin imports AHardwareBuffer directly as a VkImage:
|
||||
@@ -226,6 +243,28 @@ adb logcat -s Unity MosisSDK Vulkan
|
||||
- Check XR input device selection matches controller
|
||||
- Test with mouse click fallback in editor
|
||||
|
||||
### Build Fails with "glad/gles2.h not found"
|
||||
|
||||
This error occurs when IL2CPP tries to compile native plugin C++ files. The `.meta` files for the cpp/h files must have `PluginImporter` settings with `enabled: 0` for all platforms to exclude them from IL2CPP.
|
||||
|
||||
**Solution**: Ensure all `.meta` files in `Plugins/Android/cpp/` have proper PluginImporter exclusion settings:
|
||||
```yaml
|
||||
PluginImporter:
|
||||
platformData:
|
||||
Android:
|
||||
enabled: 0
|
||||
Any:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
# ... exclude all platforms
|
||||
```
|
||||
|
||||
### Build Fails with "getSdkDir() not found"
|
||||
|
||||
The `mainTemplate.gradle` must use `System.getenv("ANDROID_HOME")` instead of `getSdkDir()` for the ANDROID_SDK cmake argument. Ensure `ANDROID_HOME` environment variable is set.
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
### Files Modified in Vulkan Implementation
|
||||
@@ -249,3 +288,4 @@ adb logcat -s Unity MosisSDK Vulkan
|
||||
|
||||
- **1.0.0** - Initial release with OpenGL support
|
||||
- **1.1.0** - Added Vulkan backend, touch down/up events, dynamic resolution
|
||||
- **1.2.0** - Fixed IL2CPP build compatibility, added direct APK build support, fixed mainTemplate.gradle for direct builds
|
||||
|
||||
Reference in New Issue
Block a user