m (Removed "Tutorials" category) |
(Changed category) |
||
Line 98: | Line 98: | ||
|{SpaceWarpPaths.XXX}/addressables/StandaloneWindows64 | |{SpaceWarpPaths.XXX}/addressables/StandaloneWindows64 | ||
|} | |} | ||
[[Category: | [[Category:Creating parts]] |
Revision as of 12:35, 28 October 2023
This page is only for part mod. If your mod don't include parts, you can skip what follows.
Configuring the part in Unity
Prerequisites
- Having installed Unity
- Having initialized the Unity project
More resources
- Tutorial for creating a part in Unity: Tutorial: My First Part
- Tutorial for configuring a part in Unity: How to create parts for KSP2
Setting up the scene
- 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.
Associating textures to the meshes
- 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
- 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 mesh
Follow this instructions: Configuring the mesh.
Configuring the addressables
Creating the addressables
- Select all prefabs in the Asset folder and check “Addressable” in the Inspector window.
- Select all JSON in the Asset folder and check “Addressable” in the Inspector window.
- Select all icon images in the Asset folder and check “Addressable” in the Inspector window.
Creating a group of addressables
- Go to Window > Asset Management > Addressables > Groups.
- Click Create > Group > Packed Asset.
- Rename the group and move the mod elements into it.
- Rename each addressable name to remove the path. The final name must be the same as the part name + extension.
- Add the
parts_data
label to the JSON. If it does not exist, create it with “Manage labels” > “+”.
Creating a build profile
- Go to Window > Asset Management > Addressables > Groups.
- Click on Profile > Manage Profiles.
- Click on Create > Profile.
- Rename the new profile.
- For a mod with code, enter the values as follows, where XXX = the namespace of the .NET project previously configured.
Field name | Value |
---|---|
LocalBuildPath | Library/com.unity.addressables/aa/Windows/StandaloneWindows64 |
LocalLoadedPath | {XXX.XXXPlugin.Path}/addressables/StandaloneWindows64 |
For a codeless mod, enter the values as follows, where XXX = the mod's name.
Field name | Value |
---|---|
LocalBuildPath | Library/com.unity.addressables/aa/Windows/StandaloneWindows64 |
LocalLoadedPath | {SpaceWarpPaths.XXX}/addressables/StandaloneWindows64 |