More actions
The following page will guide you through setting up a new part inside Unity.
Configuring the part in Unity[edit | edit source]
Prerequisites Setting up Unity Modeling the mesh in Blender Texturing the mesh in Substance 3D Painter
Useful links (may contain outdated information) Tutorial for creating a part in Unity: https://luxstice.notion.site/Tutorial-My-First-Part-5f0cf456d7f4443d8c92658c7cc58314 Tutorial for configuring a part in Unity: https://www.youtube.com/watch?v=9fQg-oMqcH8
Setting up the scene[edit | edit source]
- Open Unity Hub.
- Open the Unity project.
- Click on the three dots in the Hierarchy menu then “Add a new scene”.
- Right-click on the scene > Save Scene.
- Save the scene in the Asset folder of the Unity project.
- In the Asset folder, create a folder for the mod.
- In this folder, create the “Materials” and “Parts” folders. This is just to keep the folder well organized.
- Delete the camera and light and import the meshes and textures into the corresponding folders.
Good practice for organizing the Assets folder Assets | \-Modname | \-Parts | \-(separate folders for the type of parts) | \-Folder for each part | \-Materials
Associating textures to the meshes[edit | edit source]
- Create a material in Unity for each material in Substance Painter (right-click on the project window > Create > Material)
- Select all materials. In the Inspector window, in Shader, select KSP > Parts > Paintable.
- For each material, assign the textures to the Albedo, Metallic, Normal, Emissive and Paintable channels.
- For Normal channels, click the “Fix Now” button.
- For each mesh, assign the materials to the corresponding locations. Click on “Apply”.
Adding meshes to the scene[edit | edit source]
- Create an Empty GameObject. Let's name it
myMod_myPart
. The name must be unique to any part in KSP2, including other mods. - Set its position to 0;0;0.
- Create another empty object as a child of this object and call it
model
. - Drop the mesh as a child of
model
. - Use the “Transform” panel to optionally modify the position, rotation and size of the mesh.
- Right click on the mesh > Prefab > Unpack completely.
- Select all colliders.
- In the Inspector window:
- Delete the “Mesh Renderer” component.
- Click on Add Component > Mesh Collider.
- Check “Convex”.
- Repeat the operation for all meshes.
Note: Materials should not have shaders.
Configuring the part data[edit | edit source]
Follow these instructions: Configuring the core part data.
Configuring the addressables[edit | edit source]
Creating the addressables[edit | edit source]
- If you followed the "Configuring the core part data" instructions linked above, you should have an addressables group set up for your mod with your prefab and JSON files already added.
- Next, select all icon images in the Asset folder and check "Addressable" in the Inspector window.