Skip to content

Instantly share code, notes, and snippets.

@julhe
Last active December 20, 2022 13:36
Show Gist options
  • Save julhe/88c9659e44a3973f740440d1f0f892d6 to your computer and use it in GitHub Desktop.
Save julhe/88c9659e44a3973f740440d1f0f892d6 to your computer and use it in GitHub Desktop.
Opens a Unity project, installs Unity if missing and (optionally) does SVN and Git automations, all with a single (double) click.
@Echo Off
rem === One-Click-Unity ===
rem Intendet to make lifes easier for less tech-savy people (and yourself) in your team by automating these tasks.
rem Features:
rem * Open a Unity project with one click.
rem * Can install specfic Unity versions if missing with a single key-stroke.
rem * (optional) SVN and Git related automation, check the comments down below.
rem Install:
rem 1) Copy this file next to your Unity project.
rem For example:
rem .../MyRepo/My-Unity-Project/
rem .../MyRepo/Unity Project - Open.bat
rem 2) Look into the config section below, and setup this variables
rem * ProjectPath: The path to your Unity project folder, relative to where you placed this file.
rem * UnityVersion: The full-length Unity version.
rem * UnityVersionInstallerUrl: The full URL form where the Unity install will be downloaded if the specific Unity version was not found on the executing machine.
rem 3) (Optional) Uncomment the checks for Git and the SVN automations. Or customize to your (team) needs.
rem Tested with Windows 10 (x64).
rem Created by: https://github.com/julhe / Julian Heinken
rem Link: https://gist.github.com/julhe/88c9659e44a3973f740440d1f0f892d6
rem License: Do what ever you want with this. It would be nice to credit me thought. :)
rem =========== CONFIG ===========
set "ProjectPath=./YOUR PROJECT FOLDER"
set "AdditionalArgs="
rem NOTE: Download URL still has to be adjusted if one changes the version.
set "UnityVersion=2021.3.15f1"
rem To get this link, go to https://unity.com/releases/editor/archive and copy the link to "Unity Setup 64-Bit" from your specific Unity version.
set "UnityVersionInstallerUrl=https://download.unity3d.com/download_unity/e8e88683f834/Windows64EditorInstaller/UnitySetup64-2021.3.15f1.exe"
rem ===============================
set "UnityPathHub=%ProgramW6432%\Unity\Hub\Editor\%UnityVersion%\Editor\Unity.exe"
set "UnityPathStandalone=%ProgramW6432%\Unity %UnityVersion%\Editor\Unity.exe"
rem Uncomment to enable a Git check and deny starting if missing.
rem First check if Git is installed (needed for some Unity packages).
rem git --version>nul
rem if ERRORLEVEL 1 (
rem echo Git is not installed.
rem echo Please install Git from https://git-scm.com/downloads first.
rem Pause>nul
rem exit
rem )
rem Uncomment to do a SVN update before starting Unity.
rem svn update
IF EXIST "%UnityPathHub%" (
rem Unity is installed via Unity Hub.
CALL :StartUnity "%UnityPathHub%"
exit
)
IF EXIST "%UnityPathStandalone%" (
rem Unity is not installed via Unity Hub.
CALL :StartUnity "%UnityPathStandalone%"
exit
)
rem Unity is not installed at all, download time!
echo Unity %UnityVersion% not found.
set "reply=y"
set /p "reply=Install Unity %UnityVersion%? (y/n): "
if /i not "%reply%" == "y" goto :eof
IF NOT EXIST "UnitySetup64-%UnityVersion%.exe" (
curl "%UnityVersionInstallerUrl%" --output UnitySetup64-%UnityVersion%.exe
)
echo Installing %UnityVersion% (don't close this window, this will take a few minutes)...
call "UnitySetup64-%UnityVersion%" /S
del UnitySetup64-%UnityVersion%.exe
CALL :StartUnity "%UnityPathStandalone%"
:StartUnity
echo (You can close this window.)
call "%~1" -projectPath %ProjectPath% %AdditionalArgs%
rem Uncomment to open the TortoiseSVN commit window after closing the project.
rem TortoiseProc.exe /command:commit /path:"."
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment