You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KSP-Toolkit/Editor
Stone_Blue 9f44928433 OMFG... last one, hopefully 2 years ago
..
MeshPostProcessor.cs Add folder-specific readmes 4 years ago
README.md OMFG... last one, hopefully 2 years ago
TexturePostProcessor.cs Add Editor scripts 4 years ago

README.md

Editor

Files for using the Unity editor

Installation

Place the "Editor" folder anywhere in your project Assets folder.

Usage

MeshPostProcessor

Used to perform various operations to models on import to unity

Add Colliders

To convert objects to colliders on import, add the following strings to the object's name:

  • _COLLIDER: Converts to a mesh collider

  • _SPHERECOLLIDER: Converts to a sphere collider

  • _CAPSULECOLLIDER: Converts to a capsule collider, with the axis along the object's longest axis

  • _BOXCOLLIDER: Converts to a box collider. The box will be aligned to the object's local coordinates

Merge Meshes

Add _MERGE to an object's name, and all its child objects meshes will be automatically merged into one. Does not work for skinned meshes

Delete Objects

Add _DEL to an object's name to delete it on import

Trim animations

Automatically removes any animations with only 2 keyframes to make them easier to edit manually

Additional Notes (when used in conjunction with Taniwhas Blender Mu Importer)

For Blender users who use Taniwhas Blender Importer to import existing .mus, the following steps & notes need to be addressed before importing your model into Unity with the MeshPostProcessor installed.

  1. You need to make sure you only suffix the name of the object, and not of the mesh, with the above operators.

  2. In Blender, you need to convert any imported collider instances to “real”.

    a) To do this, in Object Mode, select the collider instance object, then select: Object→Apply→Make Instances Real (Shift-Ctrl-A)

    b) Then move the new object back into its original place in your hierarchy. Holding Shift+Alt while dragging/dropping will keep its transforms/properties.

    c) Rename the object name, adding the appropriate operator suffix. (I suggest removing the “collider:” prefix from the mesh name, but thats just personal preference)

  3. Now you have to go into Edit Mode, and fill in all the faces in the mesh. Check that all of the created face normals are facing outside. (When you make real the collider instances, only vertices & edges seem to get created, and not faces.) This will be apparent, if upon Unity import, you get this error, or similar in the Console window:

     `Can't calculate tangents, because mesh '<your_object_name>_BOXCOLLIDER|mesh:<your_mesh_name>|Dupli|' doesn't contain normals.`
    

TexturePostProcessor

Used to perform various operations on textures on import to Unity. Configured with constants in the top of the file.

Only works on files with the extension EXTENSION (default ".png").

Specular maps

If SPEC_ENABLE is enabled (default true), textures with the suffix SPEC_TAG (default "-spec") will be copied into the alpha channel of the texture without that suffix. For example, the file foo-spec.png will be copied into the alpha channel of the imported texture foo.png.

Normal maps

If NORMAL_ENABLE is enabled (default true), textures with the suffix NORMAL_TAG (default "-spec") will be marked as normal maps on import and when KSP PartTools exports the texture. if NORMAL_GENERATE is enabled (default true), then the texture will automatically be converted from a hightmap using Unity's normal map generation tool.