Setting up Unity: Difference between revisions

From KSP 2 Modding Wiki
(Updated Importing ThunderKit)
(Minor grammar/wording edits)
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 ==
Line 14: Line 14:


=== Installing the addressables package ===
=== Installing the addressables package ===
Unity doesn’t come with this package natively, so we need to install it. Its easy!
Unity doesn’t come with this package natively, so we need to install it. It's easy!


# You start by going into ''Window>Package Manager'' on the top left area of Unity.
# You start by going into ''Window>Package Manager'' on the top left area of Unity.
# This will open a new window where you can manage '''''almost''''' all the packages inside Unity.
# 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.'''
# 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.
# 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.


=== Importing ThunderKit ===
=== Importing ThunderKit ===
ThunderKit is a package for unity. but its instalation is a bit different from the usual.
ThunderKit is a package for Unity, however it is not hosted in the official Unity package repository, so it needs to be installed directly from its GitHub repository.


# 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>https://github.com/PassivePicasso/ThunderKit.git#at3-update</code> and click Add.
# 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 and paste <code>https://github.com/PassivePicasso/ThunderKit.git#at3-update</code> and click Add.
#
#
# 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''' in the toolbar at the top of Unity.
# Go to '''Import Configuration''' and on '''Import Project Settings''' change the dropdown to '''Everything.'''
# Go to '''Import Configuration''' and in '''Import Project Settings,''' change the dropdown 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 ('''KSP2_x64.exe''').
# 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 ('''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.'''
# If Unity asks you to restart your project to disable the assembly importer, click '''Restart Project'''. It may ask you a second time after the import is finished, this time do not restart.
# If Unity asks you to restart your project to disable the assembly updater, click '''Restart Project'''. It may ask you a second time after the import is finished, this time do not restart.
# 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'''.
# 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'''.


  Sometimes, the component wont appear right after the import, if so:
  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
  Skip to the step for Importing KSP2 Unity Tools, and use the Tools/Fix Unity button.
   
  You will also need to use this button if the KSP2 components on your objects break, displaying a yellow warning triangle. With Unity 2022, this seems to happen on almost every Unity restart.
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 ===
=== 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.
# 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''' and paste <code><nowiki>https://github.com/KSP2Community/KSP2UnityTools.git</nowiki></code> and click Add.
  If you already had an earlier version installed, you will need to delete the whole "KSP2UnityTools" folder from your Assets folder and then do the installation.
  If you already had an earlier version installed, you will need to delete the whole "KSP2UnityTools" folder from your Assets folder and then do the installation.


Line 46: Line 45:


# After installing KSP2UnityTools, go to '''Tools>KSP2 Unity Tools.'''
# After installing KSP2UnityTools, go to '''Tools>KSP2 Unity Tools.'''
# Do either one of two following steps.
# Follow one of two following steps, depending on which applies for you:
# '''If you have a mod you want to copy addressables into''':
# '''If you have a mod you want to copy addressables into''':
## Select "Copy Assets Only" as the '''Build Mode'''.
## Select "Copy Assets Only" as the '''Build Mode'''.
Line 54: Line 53:
## Set '''Build Mode''' to "Everything".
## 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).
## 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.
## 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 mods ID (this is critically important).
## Input your mod's ID (this is critically important).
## Setup the rest of your mods info (these correspond to the swinfo).
## Setup the rest of your mod's 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.
# After doing 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]]

Revision as of 02:16, 31 December 2023

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.

Initializing the Unity project

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

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

Configure the Unity project

Installing the addressables package

Unity doesn’t come with this package natively, so we need to install it. It's easy!

  1. You start by going into Window>Package Manager on the top left area of Unity.
  2. This will open a new window where you can manage almost all the packages inside Unity.
  3. Go where it says Packages: In Project and change that to Unity Registry.
  4. 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.

Importing ThunderKit

ThunderKit is a package for Unity, however it is not hosted in the official Unity package repository, so it needs to be installed directly from its GitHub repository.

  1. 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 and paste https://github.com/PassivePicasso/ThunderKit.git#at3-update and click Add.
  2. The ThunderKit Settings window should open, if it doesn’t, just go to Tools>Thunderkit>Settings in the toolbar at the top of Unity.
  3. Go to Import Configuration and in Import Project Settings, change the dropdown to Everything.
  4. 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 (KSP2_x64.exe).
  5. Click Import and wait for KSP2 to be imported. If asked, click I made a backup, Go Ahead.
  6. If Unity asks you to restart your project to disable the assembly updater, click Restart Project. It may ask you a second time after the import is finished, this time do not restart.
  7. 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.
Sometimes, the component wont appear right after the import, if so:
Skip to the step for Importing KSP2 Unity Tools, and use the Tools/Fix Unity button.
You will also need to use this button if the KSP2 components on your objects break, displaying a yellow warning triangle. With Unity 2022, this seems to happen on almost every Unity restart.

Importing Unity KSP tools

  1. 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 and paste https://github.com/KSP2Community/KSP2UnityTools.git and click Add.
If you already had an earlier version installed, you will need to delete the whole "KSP2UnityTools" folder from your Assets folder and then do the installation.

Setting up swinfo.json and addressables

  1. After installing KSP2UnityTools, go to Tools>KSP2 Unity Tools.
  2. Follow one of two following steps, depending on which applies for you:
  3. If you have a mod you want to copy addressables into:
    1. Select "Copy Assets Only" as the Build Mode.
    2. In the build path select the addressables for your mod.
    3. At the bottom of the window, press Import swinfo.json and select your mods swinfo.json.
  4. If you want to build a full mod from Unity:
    1. Set Build Mode to "Everything".
    2. Set build path to where you want to output your packaged mod (you can set this later, just set it before build).
    3. 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.
    4. Input your mod's ID (this is critically important).
    5. Setup the rest of your mod's info (these correspond to the swinfo).
  5. After doing one of the previous two processes, press Set Up Addressables From Mod Info, and it should automatically set up the addressables groups for you.