Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions samples/unity-of-bugs/Assets/Editor/Builder.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions scripts/build-unity-of-bugs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
param(
[string] $UnityPath = "",
[string] $Platform = "",
[string] $BuildPath = ""
)

$ErrorActionPreference = "Stop"

. $PSScriptRoot/unity-utils.ps1
. $PSScriptRoot/../test/Scripts.Integration.Test/globals.ps1

if (-not $UnityPath)
{
$UnityPath = FindNewestUnity
}

$unityPath = FormatUnityPath $UnityPath
$buildMethod = BuildMethodFor $Platform
$projectPath = "$PSScriptRoot/../samples/unity-of-bugs"

if (-not $BuildPath)
{
$appName = GetTestAppName $buildMethod
$BuildPath = "$projectPath/Build/$appName"
}

Write-Host "Building unity-of-bugs sample for $Platform"
Write-Host " Build method: $buildMethod"
Write-Host " Output path: $BuildPath"

$unityArgs = @(
"-batchmode",
"-quit",
"-projectPath", $projectPath,
"-executeMethod", $buildMethod,
"-buildPath", $BuildPath
)

RunUnity $unityPath $unityArgs
12 changes: 2 additions & 10 deletions scripts/repack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ if (Test-Path "package-release.zip") {
assemblyalias --target-directory "package-dev/Runtime" --internalize --prefix "Sentry." --assemblies-to-alias "Microsoft*;System*"
assemblyalias --target-directory "package-dev/Editor" --internalize --prefix "Sentry." --assemblies-to-alias "Microsoft*;Mono.Cecil*"

if ($IsWindows) {
$unity_versions = Get-ChildItem "C:\Program Files\Unity\Hub\Editor\" -Directory | Select-Object -ExpandProperty Name
$unity_version = $unity_versions | Sort-Object -Descending | Select-Object -First 1
$unity_path = "C:\Program Files\Unity\Hub\Editor\${unity_version}\Editor\Unity.exe"
}
else {
$unity_versions = Get-ChildItem "/Applications/Unity/Hub/Editor/" -Directory | Select-Object -ExpandProperty Name
$unity_version = $unity_versions | Sort-Object -Descending | Select-Object -First 1
$unity_path = "/Applications/Unity/Hub/Editor/$unity_version/Unity.app/Contents/MacOS/Unity"
}
. $PSScriptRoot/unity-utils.ps1
$unity_path = FindNewestUnity

# Start up Unity to create the appropriate .meta files
Start-Process -FilePath $unity_path -ArgumentList "-quit -batchmode -nographics -logFile - -projectPath `"samples/unity-of-bugs/`"" -Wait
Expand Down
49 changes: 49 additions & 0 deletions scripts/unity-utils.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
$RunUnityLicenseRetryTimeoutSeconds = 3600
$RunUnityLicenseRetryIntervalSeconds = 60

function FindNewestUnity()
{
if ($IsWindows)
{
$hubPath = "C:\Program Files\Unity\Hub\Editor\"
}
elseif ($IsMacOS)
{
$hubPath = "/Applications/Unity/Hub/Editor/"
}
elseif ($IsLinux)
{
$hubPath = "$env:HOME/Unity/Hub/Editor/"
}
else
{
throw "Unsupported platform for Unity auto-detection"
}

if (-not (Test-Path $hubPath))
{
throw "Unity Hub Editor folder not found at: $hubPath"
}

$unityVersions = Get-ChildItem $hubPath -Directory | Select-Object -ExpandProperty Name
if ($unityVersions.Count -eq 0)
{
throw "No Unity versions found in: $hubPath"
}

$unityVersion = $unityVersions | Sort-Object -Descending | Select-Object -First 1

if ($IsWindows)
{
$unityPath = "${hubPath}${unityVersion}\Editor\Unity.exe"
}
elseif ($IsMacOS)
{
$unityPath = "${hubPath}${unityVersion}/Unity.app/Contents/MacOS/Unity"
}
else
{
$unityPath = "${hubPath}${unityVersion}/Editor/Unity"
}

Write-Host "Auto-detected Unity $unityVersion at: $unityPath"
return $unityPath
}

function RunUnity([string] $unityPath, [string[]] $arguments, [switch] $ReturnLogOutput)
{
If ($unityPath.StartsWith("docker "))
Expand Down
5 changes: 4 additions & 1 deletion test/Scripts.Integration.Test/create-project.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param(
param(
[string] $UnityPath
)

Expand Down Expand Up @@ -28,6 +28,9 @@ RunUnityCustom $UnityPath @("-batchmode", "-createProject", "$(GetNewProjectPath

Write-Log "Copying Editor scripts to integration project:"
New-Item -Path "$(GetNewProjectAssetsPath)" -Name "Editor" -ItemType "directory"
# Copy Builder.cs from unity-of-bugs sample (single source of truth)
Copy-Item "$UnityOfBugsPath/Assets/Editor/Builder.cs" -Destination "$(GetNewProjectAssetsPath)/Editor/"
# Copy remaining Editor scripts from integration test folder
Copy-Item -Recurse "$IntegrationScriptsPath/Editor/*" -Destination "$(GetNewProjectAssetsPath)/Editor/" `
-Exclude "BuildTimeOptions.cs"
New-Item -Path "$(GetNewProjectAssetsPath)" -Name "Scenes" -ItemType "directory"
Expand Down