Skip to content

Instantly share code, notes, and snippets.

@DanMillerDev
Created March 12, 2025 18:30
Show Gist options
  • Save DanMillerDev/ee566ac4b92e39ba54de0f96cebdc649 to your computer and use it in GitHub Desktop.
Save DanMillerDev/ee566ac4b92e39ba54de0f96cebdc649 to your computer and use it in GitHub Desktop.
Shell script for building a Meta Quest, AndroidXR and visionOS build in Unity via CLI batchmode
#!/bin/bash
# Set common variables for your Unity project, Replace these with your editor and project path
UNITY_PATH="/Applications/Unity/Hub/Editor/6000.1.0b8/Unity.app/Contents/MacOS/Unity"
PROJECT_PATH="/Users/dan/Documents/UnityRepos/Crossplatform_MR_GDC2025"
BUILD_OUTPUT_DIR="/Users/dan/Documents/UnityRepos/Crossplatform_MR_GDC2025/Builds"
BUILD_PROFILE_QUEST="Assets/Settings/Build Profiles/MetaQuest.asset"
BUILD_PROFILE_ANDROIDXR="Assets/Settings/Build Profiles/AndroidXR.asset"
BUILD_PROFILE_VISIONOS="Assets/Settings/Build Profiles/visionOS.asset"
# Ensure output directory exists
mkdir -p "$BUILD_OUTPUT_DIR"
# Log time and date
log() {
echo "[LOG $(date +"%Y-%m-%d %H:%M:%S")] $@"
}
# Meta Quest Build
log "Starting Meta Quest build..."
$UNITY_PATH -quit -batchmode -nographics \
-projectPath "$PROJECT_PATH" \
-activeBuildProfile "$BUILD_PROFILE_QUEST" \
-logFile "$BUILD_OUTPUT_DIR/meta_quest.log" \
-build "$BUILD_OUTPUT_DIR/meta_quest.apk" \
if [ $? -eq 0 ]; then
log "Meta Quest build completed successfully!"
else
log "Meta Quest build failed. Check the log file: $BUILD_OUTPUT_DIR/meta_quest_build.log"
exit 1
fi
# VisionOS Build
log "Starting VisionOS build..."
$UNITY_PATH -quit -batchmode -nographics \
-projectPath "$PROJECT_PATH" \
-activeBuildProfile "$BUILD_PROFILE_VISIONOS" \
-buildTarget visionos \
-logFile "$BUILD_OUTPUT_DIR/visionOS_build.log" \
-build "$BUILD_OUTPUT_DIR/visionOS"
if [ $? -eq 0 ]; then
log "VisionOS build completed successfully!"
else
log "VisionOS build failed. Check the log file: $BUILD_OUTPUT_DIR/visionOS_build.log"
exit 1
fi
# Android XR Build
log "Starting Android XR build..."
$UNITY_PATH -quit -batchmode -nographics \
-projectPath "$PROJECT_PATH" \
-activeBuildProfile "$BUILD_PROFILE_ANDROIDXR" \
-logFile "$BUILD_OUTPUT_DIR/androidxr_build.log" \
-build "$BUILD_OUTPUT_DIR/androidxr.apk" \
if [ $? -eq 0 ]; then
log "Android XR build completed successfully!"
else
log "Android XR build failed. Check the log file: $BUILD_OUTPUT_DIR/android_xr_build.log"
exit 1
fi
log "All builds completed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment