Setting up Unity: Difference between revisions

From KSP 2 Modding Wiki
mNo edit summary
Line 22: Line 22:
# Open the file with Unity Hub. When Unity opens, choose "Import" in the import window.
# Open the file with Unity Hub. When Unity opens, choose "Import" in the import window.
# The ThunderKit Settings window should open, if it doesn’t just go to '''Tools>Thunderkit>Settings''' on the top part of Unity.
# The ThunderKit Settings window should open, if it doesn’t just go to '''Tools>Thunderkit>Settings''' on the top part of Unity.
# Go to '''Import Configuration''' and on '''Import Project Settings''' change the dropdown to '''Everything.'''
# Go to '''Import Configuration''' and on '''Import Project Settings''' change the dropdown to '''Nothing.'''
# Go to '''ThunderKit Settings''' and on '''Locate and load game files for project''' click on '''Browse''' and select your '''main''' Kerbal Space Program 2 executable ('''KSP2_x64.exe''').
# Go to '''ThunderKit Settings''' and on '''Locate and load game files for project''' click on '''Browse''' and select your '''main''' Kerbal Space Program 2 executable ('''KSP2_x64.exe''').
# Click '''Import''' and wait for KSP2 to be imported, if asked click '''I made a backup, Go Ahead'''
# Click '''Import''' and wait for KSP2 to be imported, if asked click '''I made a backup, Go Ahead'''

Revision as of 21:10, 28 October 2023

This page will help you install everything you need to work your on Unity.

Installing Unity

  1. Download Unity Hub. https://unity.com/download
  2. Download Unity 2022.3.5f1. https://unity.com/releases/editor/whats-new/2022.3.5
  3. Click on “Install this version with Unity Hub”.

Initializing the Unity project

As the Unity project is very large (~4 GB), we will use it for all our mods.

  1. Follow the instructions on this page : https://luxstice.notion.site/Creating-a-Unity-Project-dae1a51ab2a84fc4b5c5e1eeef4b90b3.

For a quick presentation of the Unity interface: https://luxstice.notion.site/Learning-Unity-faf0ab10f24c4925bf4b51a997a41666.

Configure the Unity project

Importing ThunderKit

ThunderKit is a package for unity. but its instalation is a bit different from the usual.

  1. Download the latest version of ThunderKit here : https://github.com/KSP2Community/ThunderKitInstaller/releases.
  2. Open the file with Unity Hub. When Unity opens, choose "Import" in the import window.
  3. The ThunderKit Settings window should open, if it doesn’t just go to Tools>Thunderkit>Settings on the top part of Unity.
  4. Go to Import Configuration and on Import Project Settings change the dropdown to Nothing.
  5. Go to ThunderKit Settings and on Locate and load game files for project click on Browse and select your main Kerbal Space Program 2 executable (KSP2_x64.exe).
  6. Click Import and wait for KSP2 to be imported, if asked click I made a backup, Go Ahead
  7. If Unity asks you to restart your project, click Restart Project
  8. To check if the game was correctly imported, select any game object and on the inspector click Add Component then search for Core Part Data.
Sometimes, the component wont appear right after the import, if so:
1. Go to your Project window on unity
2. Open the Packages tree view and scroll to KSP2_x64
3. Right click and select "Reimport" (DON’T SELECT REIMPORT ALL, it takes way longer)
4. Wait for the folder to be reimported, once finished you should be good to go

This also fixes if Unity looses track of KSP2’s components like so. If your components look like this, do the same shown above.

Importing Unity KSP tools

  1. Download the package here : https://github.com/SpaceWarpDev/KSP2UnityTools/releases.
  2. Click on the download file then click on “Import”.

Other configurations

  1. In the project explorer, go to Assets > AddressablesAssetData > AssetGroups > Built In Data.
  2. In the Inspector window, click on “Inspect Top Level Settings”.
  3. Set the “Shader Bundle Naming Prefix” field to “Default Group GUID”.

Without this manipulation, Unity generates bundles with an ID calculated from the project name. Since we are using the same project for multiple mods, there will be a name conflict for the standard shader that Unity incorporates into all addressables. Using the GUID of the default group will help avoid collisions (you will need to remember to make the mod group the default group).