37 lines
1.4 KiB
PowerShell
37 lines
1.4 KiB
PowerShell
# CleanUnityProject.ps1
|
|
# Run this script from your root Unity project directory.
|
|
|
|
$ProjectRoot = Get-Item .
|
|
|
|
# 1. Verification checks
|
|
if (!(Test-Path (Join-Path $ProjectRoot "Assets")) -or !(Test-Path (Join-Path $ProjectRoot "ProjectSettings"))) {
|
|
Write-Error "Error: This does not look like a Unity project root directory. 'Assets' or 'ProjectSettings' folder missing."
|
|
Exit
|
|
}
|
|
|
|
Write-Host "Starting Unity project cleanup in: $($ProjectRoot.FullName)" -ForegroundColor Cyan
|
|
|
|
# 2. Define folders and files safe to delete
|
|
$TargetFolders = @("Library", "Temp", "Logs", "obj","Builds")
|
|
$TargetExtensions = @("*.csproj", "*.sln", "*.userprefs")
|
|
|
|
# 3. Delete target directories
|
|
foreach ($Folder in $TargetFolders) {
|
|
$FolderPath = Join-Path $ProjectRoot $Folder
|
|
if (Test-Path $FolderPath) {
|
|
Write-Host "Removing directory: $Folder..." -ForegroundColor Yellow
|
|
Remove-Item -Path $FolderPath -Recurse -Force -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
|
|
# 4. Delete target IDE files
|
|
foreach ($Ext in $TargetExtensions) {
|
|
$Files = Get-ChildItem -Path $ProjectRoot -Filter $Ext
|
|
foreach ($File in $Files) {
|
|
Write-Host "Removing file: $($File.Name)..." -ForegroundColor Yellow
|
|
Remove-Item -Path $File.FullName -Force -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
|
|
Write-Host "Cleanup complete! It is now safe to back up your project or open it fresh in Unity." -ForegroundColor Green
|