Setting up Unity: Difference between revisions

From Kerbal Space Program 2 Modding Wiki
Jump to navigation Jump to search
Spacewarp>Cheese
Tell people to use KSP2UT to fix unity
mNo edit summary
 
(14 intermediate revisions by 5 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 from https://unity.com/download.
# Download Unity Hub from https://unity.com/download.
# 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/Clone/Use the Redux.Template repo from https://github.com/KSP2Redux/Redux.Template


== Initializing the Unity project ==
== Initializing the Unity project ==
# Follow the instructions on this page: https://luxstice.notion.site/Creating-a-Unity-Project-dae1a51ab2a84fc4b5c5e1eeef4b90b3 but use Unity 2022.3.5f1 instead.
# 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.


<blockquote>For a quick presentation of the Unity interface: https://luxstice.notion.site/Learning-Unity-faf0ab10f24c4925bf4b51a997a41666.</blockquote>
== Configuring the Unity project ==


== Configure 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


=== Installing the addressables package ===
# The ''ThunderKit'' Settings window should open, if it doesn’t, just go to '''Tools>ThunderKit>Settings''' in the toolbar at the top of Unity.
Unity doesn’t come with this package natively, so we need to install it. Its easy!
# 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.'''


# You start by going into ''Window>Package Manager'' on the top left area of Unity.
=== Creating a mod and setting up swinfo.json ===
# This will open a new window where you can manage '''''almost''''' all the packages inside Unity.
# Go where it says '''Packages: In Project''' and change that to '''Unity Registry.'''
# On the search bar, look for '''Addressables'''. Select it and click install! It will show a couple pop-ups, and once its finished, it will show a green checkmark next to the Addressables’s version.


=== Importing ThunderKit ===
# Go to '''Modding>KSP2 Unity Tools.'''
ThunderKit is a package for unity. but its instalation is a bit different from the usual.
# Click Create Mod
 
# Give the mod a ModId and if you want a small code template in your mod, click '''Add Code to Mod.'''
# Go to '''Window>Package Manager''' and click on the '''+''' sign on the top left corner of the window that opens, after that click on Add Package from Git URL and paste <code><nowiki>https://github.com/PassivePicasso/ThunderKit.git</nowiki></code> and click Add.
# Click Create.
# Download the latest version of ThunderKit Installer here : https://github.com/KSP2Community/ThunderKitInstaller/releases.
# 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.
# Open the file with Unity Hub. When Unity opens, choose "Import" in the import window.
# Setting up swinfo is simple. Select swinfo.asset and edit all the values to your liking.
# Go to '''Tools>Thunderkit>Reinstall'''.
# 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.'''
# The ThunderKit Settings window should open, if it doesn’t just go to '''Tools>Thunderkit>Settings''' on the top part of Unity.
# 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.'''
# Go to '''Import Configuration''' and on '''Import Project Settings''' change the dropdown to '''Nothing.'''
# 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.
# 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'''
# If Unity asks you to restart your project, click '''Restart Project'''
# 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. Skip to the step for Importing KSP2 Unity Tools, and use the Tools/Fix Unity button
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 ===
 
# Go to '''Window>Package Manager''' and click on the '''+''' sign on the top left corner of the window that opens, after that click on '''Add Package from Git URL''' and paste <code><nowiki>https://github.com/KSP2Community/KSP2UnityTools.git</nowiki></code> and click Add.
If it's already installed, you'll need to delete the whole "KSP2UnityTools" folder from your Assets folder and then do the installation.
 
=== Setting up swinfo.json and addressables ===
 
# After installing KSP2UnityTools, go to '''Tools>KSP2 Unity Tools.'''
# Do either one of two following steps.
# '''If you have a mod you want to copy addressables into''':
## Select "Copy Assets Only" as the '''Build Mode'''.
## In the build path select the addressables for your mod.
## At the bottom of the window, press '''Import swinfo.json''' and select your mods swinfo.json.
# '''If you want to build a full mod from Unity''':
## Set '''Build Mode''' to "Everything".
## Set build path to where you want to output your packaged mod (you can set this later, just set it before build).
## If you already have a swinfo, you can skip the next steps using the import swinfo.json as described in the previous section.
## Input your mods ID (this is critically important).
## Setup the rest of your mods info (these correspond to the swinfo).
# After doing one of the previous two processes, press '''Set Up Addressables From Mod Info''', and it should automatically set up everything needed in addressables so you dont need to touch it.


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