Modding/Tutorial/Setting Up Unity Project: In Depth

WIP Page: Please add data

1. Download Unity Hub
	1. Select Installs > Install Editor: Unity 2019.4.30f or the current Uboat Unity Version *(2019.4.30.f editor is not available to install from the Unity Hub app - you will need to download it here: https://unity3d.com/get-unity/download/archive, then install it, then click Installs > Locate to point to the installed editor)*
2. Open the Uboat Launcher>Mods
	1. Create Mod
		1. Mod Name: Whatever you Like (you change it later)
		2. Description: Describe your mod with words (you change it later)
		3. Preview image: an image "preview.jpg" which is displayed on the Workshop Page (you change it later and further images can be added after submission to the Steam Workshop)
		4. Template: Unity Project
	2. Select a path for you Unity project (this is your space to work in, and is a separate location from where the mod is deployed)
3. Unity Hub > Projects > Open > Add project from disk
	1. Locate your mod's project directory from step 2.2
4. Let Unity build itself... Once complete:
	* Unity may prompt you for the game assemblies: Provide the path of the Uboat.exe ../Steam/steamapps/common/uboat/uboat.exe
	* Unity may also ask about scripts and/or assemblies that use obsolete API's. you do not want to upgrade, choose "No thanks"
	* Tools > Update Game Assemblies
		1. Unity will pull in Uboat's game assembly libraries
5. At this point you can start building anything. However there are some steps that help keep some bugs from occurring with unity projects
	1. Add an Assembly Definition
		1. Under Assets/Mods/<mod>/
		2. Right mouse click > Create > Assembly Definition. Name it whatever you would like (this name does not appear anywhere outside the project - players will not see it)
	2. Rebuild the Manifest file:
		1. Under Assets/Packages/<mod>/Manifest
		2. Delete this file
		3. Right mouse click > Create > Asset Bundle Descriptor
		4. Tools > Validate Asset Bundle Manifest
		5. You should see the manifest populate with 'Contained Assets' which will have 0 items in it. Whenever you add things to your project again, use Validate Asset Bundle Manifest and this list will include any game objects, textures, materials, audio you add.
6. Some tips
	1. Assets/Mods/<mod> is the folder structure that will be deployed (copied) into your local Uboat Mod directory (in App Data)
		1. Asset Bundles will automatically be put into Assets/Mods/<mod>/Bundles
		2. It is a good idea to create a 'Data Sheet' Folder if you intend to add Excel Data for the game to use
		3. It is a good idea to create 'Source' Folder here if you intend to add code
		4. It is a good idea to link Unity and Visual Studio together, otherwise ensure you have a capable text editor (such as Notepad++) to modify/view manifest, meta and data files.
7. I want to replace a game texture
	1. Load the Uboat game with the Uboat Inspector Mod
	2. After the game had started find the texture you want to replace in the Inspector > Assets tab
	3. Select the file. Example: Icons/Map/Freighter
		1. Save the file
		2. This will also create a <image>.meta file < this is useful if you want to reference a vanilla texture (via GUID) without duplicating it into your mod, or reference some of the Unity settings used for the asset in the vanilla game.
		3. Open in your favorite photo editing software
		4. make changes / or completely replace the image with a new one
	4. Place New/Modified Image (drag and drop) in to Unity
		1. Example: Assets/Packages/<mod>/Icons/Map/Freighter.png
		2. Apply proper settings to the image file in Unity:
			1. This image was a UI / Sprite: so under the Freighter Settings in Unity select Sprite UI
			2. in the case of UI elements it is usually intended to have the alpha channel enabled
			3. if you are making really large textures, it can be a good idea to apply compression (Medium) as well as enable 'Use Crunch Compression' to reduce Asset Bundle Size
			4. for UI elements you dont have to generate MIP maps (pregenerated low resolution textures) however if making a texture for a game object or material. this might be a good idea to help reduce load on a GPU. and improve performance
8. Tools>Validate Asset Bundle Manfiests ... Just in case
9. Tools>Build Mod
10. Open Uboat Launcher > Enable your local mod > Test
11. Happy? No: Return to Step 7. Yes: Continue...
12. Launcher>Mods>Upload to workshop
	1. A Steam Workshop Id will be created and populated in the manifest located in the Local Mod Directory
	2. It is a good Idea to take a copy of the Deployed Manifest File and Place it into your Unity Project (overwriting the default template) so you don't have to recreate it after deploying new changes