Unity Build Tool

From Levi D. Smith Games Wiki
Jump to: navigation, search

Instructions for the Unity Build Tool

Installation

The latest Unity Build Tool can be downloaded at https://bitbucket.org/gatechgrad/unityhelper/src/default/

Download and install Ruby if you don't already have it.

https://www.ruby-lang.org/en/

Navigate to the UnityHelper directory and run:

> ruby unity_version_gui.rb

Install the following gems

> gem install gtk3

> get install rubyzip

> gem install win32-sound

> gem install fileutils


Edit settings unity_version.config to match your Unity settings

  • PROJECTS_DIR - where the Unity projects are located
  • UNITY_CURRENT_VERSION - the current version of Unity. Previously auto-detected, but was broken with the new Unity hub. Need to determine if there is a new way to get the Unity version
  • PLAYMAKER_CURRENT_VERSION - current version of PlayMaker
  • UNITY_EXE - location of the main Unity executable
  • SCAN_PROJECTS_ON_STARTUP - loads project listing on startup. Set this to false to speed startup
  • COMPANY_NAME - Used for setting the company / author name in the project settings

Possible enhancement - add config window to enter these values


Unitybuildtool 20190630.jpg

Compile Selected

Check the checkboxes to compile for the selected platforms

  • Windows - make Windows build
  • Mac - make MacOS build
  • Linux - make Linux build
  • WebGL - make WebGL build
  • Make ZIP files - ZIPs all folders in the build folder

All builds will be placed in the "build" folder for their respective projects. Windows, Mac, and Linux use the command line build method. WebGL creates an Editor script and adds the appropriate scenes and programmatically builds the projects.

WebGL zip files will use the slug + .zip as the file name, and will be copied to the main uploads folder. This was changed to make uploading to host server easier, and it can use the file name to determine the appropriate directory for extraction.

Scan Projects

Reloads the main project list. Called when the Unity Build Tool is started, if the SCAN_PROJECTS_ON_STARTUP config setting is set to true.

Find Unity Scenes

For the selected projects, display all .unity files anywhere in the project folder

Clear build folder

Delete all files in the "build" folder for the selected projects

Open build folder

Open the "build" folder in Windows Explorer for each selected project

Clear VS files

Delete all .csproj and .sln files in the main project directory for each selected project. Useful for cleaning up old legacy Visual Studio project files that are no longer needed.

Remove Default Packages

Attempts to remove the default packages installed by Unity.

  • com.unity.textmeshpro
  • com.unity.ads
  • com.unity.analytics
  • com.unity.purchasing
  • com.unity.collab-proxy
  • com.unity.multiplayer-hlapi
  • com.unity.timeline
  • com.unity.xr.legacyinputhelper

Adds PackageRemover.cs to the Editor folder, and calls PackageRemover.RemovePackages.

Due to a domain/locking error that is thrown during removal, this call will fail when run from the Unity Build Tool, but it should work by selecting Build > Package Remover in the project.

Note - The removal will fail if there are errors related to TextMeshPro needing to be .NET 4.0 scripting. Set scripting in PlayerSettings to 4.0 before running RemovePackages.

Possible enhancement - make selectable list of packages

Update API

This will update the selected projects to the current Unity version, without prompting for each selected project.

Calls the following by command line

<unity executable> -accept-apiupdate -batchmode -quit -projectPath <project path>


Update Project Settings

Sets the project company to the COMPANY_NAME defined in the config file

Set the .NET script version to latest version (4.0) (resolves TextMeshPro errors)

This creates the Editor/UpdateProjectSettings.cs file for each selected project, and calls UpdateProjectSettings.UpdateSettings

Note - TextMeshPro may still have to be manually removed or project version manually updated, since the script will be unable to run due to the TextMeshPro script version errors.

Copy Scripts

Copies AutoSave.cs and PackageRemover.cs to Editor folder

AutoSave.cs saves the project whenever the play button is pressed in the Unity editor. This is very helpful in the case that the program gets stuck in an endless loop. If you have to kill Unity, then you won't lose all of your work.

Copies splash_background.jpg and splash_logo.jpg to the Assets/Sprites/SplashScreen folder. Still have to manually convert the images files to 2D/UI, and assign them under player settings. May be possible to automate this.

May want to remove PackageRemover.cs, since it's already copied in Remove Default Packages

Make Upload Script

Makes Windows batch file (butler_push_all.bat) to upload builds to Itch.io. Prompts for Itch.io identifier for each selected project.

Requires butler.bat in ..\..\tools\butler.bat.

 butler.bat
 C:\Users\<username>\AppData\Roaming\itch\broth\butler\versions\<itch_version>\butler %*

Enter Slug

Prompts for Slug value of all selected projects. Should match the Wordpress slug of the game page. Used for creating WebGL ZIP files, which should match the Wordpress slug for the game page. May also be used in place of the Itch.io identifier in an update, but that requires that the Itch.io identifier for the game match the slug.

Ignore

Copies the selected projects to the ignore.config file. Projects in the ignore.config file are not displayed. Useful for not displaying Godot or other Unity projects that don't need to be managed.

Display Package Cache

Display the contents of the Library/PackageCache folder for the selected projects. Useful for determining which projects have unneeded packages installed that can be removed.