|
67 | 67 |
|
68 | 68 | # try to find unity executable |
69 | 69 | unity_project_version_path="OneSignalExample/ProjectSettings/ProjectVersion.txt" |
70 | | -unity_project_version=$(cat ${unity_project_version_path} | sed -n 's/^m_EditorVersion: //p') |
71 | | -unity_versions_path="/opt/unity/Editor/Unity" |
72 | | -unity_path="${unity_versions_path}/${unity_project_version}" |
73 | | - |
74 | | -if [[ ! -d "${unity_versions_path}" ]] |
75 | | -then |
76 | | - echo "Could not find any versions of Unity installed at path: ${unity_versions_path}" |
77 | | - exit 1 |
78 | | -elif [[ ! -d "${unity_path}" ]] |
79 | | -then |
80 | | - echo "Could not find Unity ${unity_project_version}" |
81 | | - pushd "${unity_versions_path}" > /dev/null 2>&1 |
82 | | - |
83 | | - options=(* "Exit") |
84 | | - PS3="Please select an installed Unity version: " |
85 | | - select option in "${options[@]}" |
86 | | - do |
87 | | - if [[ "$option" = "Exit" ]] |
88 | | - then |
89 | | - exit 1 |
90 | | - elif [[ "${options[@]}" =~ "$option" ]] |
91 | | - then |
92 | | - echo "Using ${option}" |
93 | | - unity_path="${unity_versions_path}/${option}" |
94 | | - break |
95 | | - fi |
96 | | - done |
| 70 | +unity_project_version=$(cat "${unity_project_version_path}" | sed -n 's/^m_EditorVersion: //p') |
| 71 | + |
| 72 | +# Unity project path from CI environment if available |
| 73 | +unity_project_path="${UNITY_PROJECT_PATH:-OneSignalExample}" |
| 74 | + |
| 75 | +# Common installation locations (CI, macOS, local) |
| 76 | +unity_candidates=( |
| 77 | + "/opt/unity/Editor/Unity" # Linux runner (GitHub Actions) |
| 78 | + "/Applications/Unity/Hub/Editor/${unity_project_version}/Unity.app/Contents/MacOS/Unity" # macOS |
| 79 | + "/home/runner/Unity/Hub/Editor/${unity_project_version}/Editor/Unity" # legacy Linux path |
| 80 | + "/home/runner/Unity/Hub/Editor/${unity_project_version}/Unity.app/Contents/MacOS/Unity" # legacy macOS path |
| 81 | +) |
| 82 | + |
| 83 | +unity_executable="" |
| 84 | +for candidate in "${unity_candidates[@]}"; do |
| 85 | + if [[ -x "$candidate" ]]; then |
| 86 | + unity_executable="$candidate" |
| 87 | + break |
| 88 | + fi |
| 89 | +done |
97 | 90 |
|
98 | | - popd > /dev/null 2>&1 |
| 91 | +if [[ -z "$unity_executable" ]]; then |
| 92 | + echo "❌ Could not locate Unity executable for version ${unity_project_version}" |
| 93 | + echo "Checked the following paths:" |
| 94 | + printf ' - %s\n' "${unity_candidates[@]}" |
| 95 | + exit 1 |
| 96 | +else |
| 97 | + echo "✅ Found Unity executable: ${unity_executable}" |
99 | 98 | fi |
100 | 99 |
|
101 | | -unity_executable="${unity_path}/Unity.app/Contents/MacOS/Unity" |
102 | | - |
103 | 100 | # VERSION file will act as the source of truth |
104 | 101 | version_filepath="OneSignalExample/Assets/OneSignal/VERSION" |
105 | 102 | current_version=$(cat "$version_filepath") |
|
0 commit comments