Setting up Unity: Difference between revisions

From Kerbal Space Program 2 Modding Wiki
Jump to navigation Jump to search
Spacewarp>Polo
mNo edit summary
 
(24 intermediate revisions by 7 users not shown)
Line 1: Line 1:
This page will help you install everything you need to work your on Unity.
This page will help you install everything you need to use Unity for KSP2 modding.


== Installing Unity ==
== Installing Unity ==


# Download Unity Hub. https://unity.com/download
# Download Unity Hub from https://unity.com/download.
# Download Unity 2022.3.5f1. https://unity.com/releases/editor/whats-new/2022.3.5
# Download Unity 2022.3.5f1 by clicking on the '''Install this version with Unity Hub''' link on this page: https://unity.com/releases/editor/whats-new/2022.3.5.
# Click on “Install this version with Unity Hub”.
# Download and install Git from https://git-scm.com/downloads.
# Download/Clone/Use the Redux.Template repo from https://github.com/KSP2Redux/Redux.Template


== Initializing the Unity project ==
== Initializing the Unity project ==
As the Unity project is very large (~4 GB), we will use it for all our mods.
# Open '''Unity Hub'''.
# Click on '''Add''' at the top right of the window.
# Click on '''Add project from disk.'''
# Select the Redux template you downloaded.


# Follow the instructions on this page : https://luxstice.notion.site/Creating-a-Unity-Project-dae1a51ab2a84fc4b5c5e1eeef4b90b3.
== Configuring the Unity project ==


<blockquote>For a quick presentation of the Unity interface: https://luxstice.notion.site/Learning-Unity-faf0ab10f24c4925bf4b51a997a41666.</blockquote>
=== Configuring ThunderKit ===
''ThunderKit'' is a package for Unity which we use to import the game's components into the Unity editor. This is included with the Redux Template


== Configure the Unity project ==
# The ''ThunderKit'' Settings window should open, if it doesn’t, just go to '''Tools>ThunderKit>Settings''' in the toolbar at the top of Unity.
# Go to '''ThunderKit Settings''' and in '''Locate and load game files for project,''' click on '''Browse''' and select your main Kerbal Space Program 2 executable found at <code><KSP2 root folder>/KSP2_x64.exe</code>. '''Note: This must be a Redux install of the game.'''
# Click '''Import''' and wait for KSP2 to be imported. If asked, click '''I made a backup, Go Ahead'''.
# If Unity asks you to restart your project, confirm it by clicking on '''Restart Project'''.
# After the process is finished, to check if the game was correctly imported, select or create any game object and in the inspector click '''Add Component''' and search for '''Core Part Data.'''
# Once you've confirmed that Core Part Data is there, you now have to browse to '''Assets -> and find ImportKsp2ToEditor.'''
# Once you've found ImportKsp2ToEditor, click on it and press '''Execute.'''


=== Importing ThunderKit ===
=== Creating a mod and setting up swinfo.json ===
ThunderKit is a package for unity. but its instalation is a bit different from the usual.


# Download the latest version of ThunderKit here : https://github.com/KSP2Community/ThunderKitInstaller/releases.
# Go to '''Modding>KSP2 Unity Tools.'''
# Open the file with Unity Hub. When Unity opens, choose "Import" in the import window.
# Click Create Mod
# The ThunderKit Settings window should open, if it doesn’t just go to '''Tools>Thunderkit>Settings''' on the top part of Unity.
# Give the mod a ModId and if you want a small code template in your mod, click '''Add Code to Mod.'''
# Go to '''Import Configuration''' and on '''Import Project Settings''' change the dropdown to '''Everything.'''
# Click Create.
# 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''').
# You should now have a folder with your mod name with a swinfo asset, Pipelines folder and if you ticked Add Code to Mod, a Code folder.
# Click '''Import''' and wait for KSP2 to be imported, if asked click '''I made a backup, Go Ahead'''
# Setting up swinfo is simple. Select swinfo.asset and edit all the values to your liking.
# If Unity asks you to restart your project, click '''Restart Project'''
# If you want to test your mod in the editor, navigate to KSP2 Unity Tools, select your mod and then click '''Test Selected Mods in Editor.'''
# 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'''.
# Once you've finished your mod and are ready to distribute it, you will have to export it. Select the mod in KSP2 Unity Tools and then click '''Deploy Selected Mods To Zip File.'''
# The mod will then be stored in the Redux.Template in a folder called "Deploy". You will then have to share the zip on SpaceDock or whichever other websites you please.


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 ===
# Download the package here : https://github.com/SpaceWarpDev/KSP2UnityTools/releases.
# Click on the download file then click on “Import”.
=== Other configurations ===
# In the project explorer, go to Assets > AddressablesAssetData > AssetGroups > Built In Data.
# In the Inspector window, click on “Inspect Top Level Settings”.
# Set the “Shader Bundle Naming Prefix” field to “Default Group GUID”.
<blockquote>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).</blockquote>
[[Category:Getting started]]
[[Category:Getting started]]

Latest revision as of 18:28, 16 November 2025

This page will help you install everything you need to use Unity for KSP2 modding.

Installing Unity

  1. Download Unity Hub from https://unity.com/download.
  2. Download Unity 2022.3.5f1 by clicking on the Install this version with Unity Hub link on this page: https://unity.com/releases/editor/whats-new/2022.3.5.
  3. Download and install Git from https://git-scm.com/downloads.
  4. Download/Clone/Use the Redux.Template repo from https://github.com/KSP2Redux/Redux.Template

Initializing the Unity project

  1. Open Unity Hub.
  2. Click on Add at the top right of the window.
  3. Click on Add project from disk.
  4. Select the Redux template you downloaded.

Configuring the Unity project

Configuring ThunderKit

ThunderKit is a package for Unity which we use to import the game's components into the Unity editor. This is included with the Redux Template

  1. The ThunderKit Settings window should open, if it doesn’t, just go to Tools>ThunderKit>Settings in the toolbar at the top of Unity.
  2. Go to ThunderKit Settings and in Locate and load game files for project, click on Browse and select your main Kerbal Space Program 2 executable found at <KSP2 root folder>/KSP2_x64.exe. Note: This must be a Redux install of the game.
  3. Click Import and wait for KSP2 to be imported. If asked, click I made a backup, Go Ahead.
  4. If Unity asks you to restart your project, confirm it by clicking on Restart Project.
  5. After the process is finished, to check if the game was correctly imported, select or create any game object and in the inspector click Add Component and search for Core Part Data.
  6. Once you've confirmed that Core Part Data is there, you now have to browse to Assets -> and find ImportKsp2ToEditor.
  7. Once you've found ImportKsp2ToEditor, click on it and press Execute.

Creating a mod and setting up swinfo.json

  1. Go to Modding>KSP2 Unity Tools.
  2. Click Create Mod
  3. Give the mod a ModId and if you want a small code template in your mod, click Add Code to Mod.
  4. Click Create.
  5. You should now have a folder with your mod name with a swinfo asset, Pipelines folder and if you ticked Add Code to Mod, a Code folder.
  6. Setting up swinfo is simple. Select swinfo.asset and edit all the values to your liking.
  7. If you want to test your mod in the editor, navigate to KSP2 Unity Tools, select your mod and then click Test Selected Mods in Editor.
  8. Once you've finished your mod and are ready to distribute it, you will have to export it. Select the mod in KSP2 Unity Tools and then click Deploy Selected Mods To Zip File.
  9. The mod will then be stored in the Redux.Template in a folder called "Deploy". You will then have to share the zip on SpaceDock or whichever other websites you please.