Setting up Unity: Difference between revisions

From Kerbal Space Program 2 Modding Wiki
Jump to navigation Jump to search
m 21 revisions imported
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 6: Line 6:
# 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.
# 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.
# Download and install Git from https://git-scm.com/downloads.
# 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 ==
# Open '''Unity Hub'''.
# Open '''Unity Hub'''.
# Click on '''New Project''' at the top right of the window.
# Click on '''Add''' at the top right of the window.
# At the top of the new interface, set the '''Editor Version''' to <code>2022.3.5f1</code>. You can keep the project template set to '''3D (Core)'''.
# Click on '''Add project from disk.'''
# Set the '''Project name''', it can be whatever you want like for example <code>MyModId.Unity</code>.
# Select the Redux template you downloaded.
# Set the '''Location''' to the folder you want the Unity project to be saved in.
# Click '''Create project'''.
 
<blockquote>For a quick presentation of the Unity interface: https://luxstice.notion.site/Learning-Unity-faf0ab10f24c4925bf4b51a997a41666.</blockquote>


== Configuring the Unity project ==
== Configuring the Unity project ==


=== Installing the Addressables package ===
=== Configuring ThunderKit ===
Unity doesn’t come with this package natively, so we need to install it first:
''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


# Open the Package Manager by clicking '''Window>Package Manager''' in the toolbar at the top of Unity.
# This will open a new window where you can manage most of the packages in your project.
# Go where it says '''Packages: In Project''' and change that to '''Unity Registry'''.
# In the search bar, look for '''Addressables'''. Select it and click '''Install'''. It will show a couple pop-ups, and once it is finished, it will show a green checkmark next to the '''Addressables''' package version.
=== Installing ThunderKit ===
''ThunderKit'' is a package for Unity which we use to import the game's components into the Unity editor. However, it is not hosted in the official Unity package repository and needs to be installed directly from its GitHub repository.
# Go to '''Window>Package Manager''' and click on the '''+''' sign in the top left corner of the window that opens, after that click on '''Add Package from Git URL''', paste <code>https://github.com/PassivePicasso/ThunderKit.git</code> and click '''Add'''.
# The ''ThunderKit'' Settings window should open, if it doesn’t, just go to '''Tools>ThunderKit>Settings''' in the toolbar at the top of Unity.
# 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 '''Import Configuration''' and in '''Import Project Settings,''' change the dropdown value to '''Everything.'''
# 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.'''
# 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>.
# 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'''.
# If Unity asks you to restart your project, confirm it by clicking on '''Restart Project'''.
# 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'''.
# 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.'''
=== Installing KSP2 Unity Tools ===
# Once you've found ImportKsp2ToEditor, click on it and press '''Execute.'''
 
# Go to '''Window>Package Manager''' and click on the '''+''' sign in the top left corner of the window that opens, after that click on '''Add Package from Git URL''', paste <code>https://github.com/KSP2Community/KSP2UnityTools.git</code> and click '''Add'''.
If you have previously installed an older version of KSP2 Unity Tools manually from a .unitypackage file, you will need to delete the whole "KSP2UnityTools" folder from your Assets folder and then do the installation.


=== Setting up swinfo.json and addressables ===
=== Creating a mod and setting up swinfo.json ===


# After installing KSP2UnityTools, go to '''Tools>KSP2 Unity Tools.'''
# Go to '''Modding>KSP2 Unity Tools.'''
# Follow one of two following steps, depending on which applies for you:
# Click Create Mod
# '''If you have a mod you want to copy addressables into''':
# Give the mod a ModId and if you want a small code template in your mod, click '''Add Code to Mod.'''
## Set '''Build Mode''' to "'''Copy Assets Only'''".
# Click Create.
## In the build path select the <code>addressables</code> folder in your mod's directory.
# 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.
## At the bottom of the window, press '''Import swinfo.json''' and select your mod's <code>swinfo.json</code>.
# Setting up swinfo is simple. Select swinfo.asset and edit all the values to your liking.
# '''If you want to build a full mod from Unity''':
# 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.'''
## Set '''Build Mode''' to "'''Everything'''".
# 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.'''
## Set build path to where you want to output your packaged mod (you can set this later, just set it before build).
# 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.
## If you already have a swinfo.json file, you can skip the next steps using the import swinfo.json button as described in the previous section.
## Input your mod's ID (this is critically important).
## Setup the rest of your mod's info (these correspond to the swinfo).
# After following one of the previous two processes, press '''Set Up Addressables From Mod Info''', and it should automatically set up the addressables groups for you.


[[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.