Last active
June 15, 2020 11:40
-
-
Save yanonono/4a359466533334ce5fea12a6f24dcd66 to your computer and use it in GitHub Desktop.
VRChat用のUnityProjectを作成するPowershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # VRChat用のUnityProjectを作成するPowershell | |
| # - 2020/06/14 初版 | |
| # - 2020/06/15 Powershell 5.x系対応 | |
| $SDKURL = 'https://vrchat.com/download/sdk2' | |
| $UNITY_VERSION = "2018.4.20f1" | |
| $NOWDATE = (Get-Date).ToLocalTime().ToString("yyyyMMdd-HHmmss") | |
| $PREFIX_NAME = "vrchat-" | |
| $DISPLAY_UNITYEDIER = $false | |
| ### VRCSDK2のバージョンチェック | |
| try { | |
| Write-Host "check vrchat sdk2 public version." | |
| $curlResult = cmd /C "curl -si $SDKURL" | |
| $temp_name = "" | |
| foreach ($str in $curlResult.Split(" ")) { | |
| if ($str.StartsWith("https") -And $str.EndsWith(".unitypackage")) { | |
| $temp_name = $str.Split('/') | |
| } | |
| } | |
| $sdkPackage = $temp_name[-1] | |
| } | |
| catch { | |
| Write-Host $Error[0] | |
| } | |
| ### VRCSDK2 ダウンロード処理 | |
| try { | |
| if (Test-Path(".\$sdkPackage")) { | |
| Write-Host "skip vrchat sdk2 download." | |
| } | |
| else { | |
| $requestResult = Invoke-WebRequest $SDKURL -OutFile ".\$sdkPackage" | |
| Write-Host "vrchat sdk2 download complete." | |
| } | |
| } | |
| catch { | |
| Write-Host "error: vrchat sdk2 download." | |
| $error[0] | |
| } | |
| ### | |
| $sdkPath = (Resolve-Path ".\$sdkPackage").Path | |
| $unityPath = "$env:ProgramFiles\Unity\Hub\Editor\$UNITY_VERSION\Editor\Unity.exe" | |
| $projectPath = (Convert-Path .) + "\" + $PREFIX_NAME + $NOWDATE | |
| if ($DISPLAY_UNITYEDIER -eq $true) { | |
| $ENABLE_UNITYEDIER = " " # スペースがないとPowershell 5.x系でエラー | |
| } | |
| else { | |
| $ENABLE_UNITYEDIER = "-batchmode -nographics" | |
| } | |
| if (Test-Path($unityPath)) { | |
| Write-Host "start unity: $unityPath" | |
| Start-Process "$unityPath" -Wait -ArgumentList $ENABLE_UNITYEDIER, "-quit", ` | |
| "-createProject", `"$projectPath`" | |
| Write-Host " create project: $projectPath" | |
| if (Test-Path($sdkPath)) { | |
| Start-Process "$unityPath" -Wait -ArgumentList $ENABLE_UNITYEDIER, "-quit", ` | |
| "-projectPath", `"$projectPath`", ` | |
| "-importPackage", `"$sdkPath`" | |
| Write-Host " import package: $sdkPath.Path" | |
| } | |
| #Dynamic bones | |
| $DynamicBonePath = $env:APPDATA + "\Unity\Asset Store-5.x\Will Hong\ScriptingAnimation\Dynamic Bone.unitypackage" | |
| if (Test-Path($DynamicBonePath)) { | |
| Start-Process "$unityPath" -Wait -ArgumentList $ENABLE_UNITYEDIER, "-quit", ` | |
| "-projectPath", `"$projectPath`", ` | |
| "-importPackage", `"$DynamicBonePath`" | |
| Write-Host " import package: Dynamic Bone($DynamicBonePath)" | |
| } | |
| Write-Host "end unity: $unityPath" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment