|
1 | 1 | # Unity Plane Mesh Splitter
|
2 |
| -A simple script which let's you split any mesh into smaller chunks. At first it was designed to work with imported Tiled2Unity terrains, but I rewrote it to work with everything you can throw at it. This is my very first public project ever. |
3 | 2 |
|
4 |
| -# Features |
5 |
| -- Very simple. |
6 |
| -- Customizable grid size. |
7 |
| -- You can choose which axes you want to use. Any combination should work. |
8 |
| -- UVs and Normals work. |
| 3 | +A simple tool which lets you split any mesh into smaller submeshes. At first it was designed to work with imported Tiled2Unity terrains, but I rewrote it to work with everything you can throw at it. |
| 4 | + |
| 5 | +### What is the purpose of this tool? |
| 6 | + |
| 7 | +Say you have a gigantic terrain in a single mesh. Unity is going to process the entire mesh when rendering it (even though only a small section in front of the camera is visible). This tool lets your split this large mesh into smaller submeshes which should greatly improve the performance thanks to the built-in Unity frustum culling (only visible meshes will be rendered). |
| 8 | + |
| 9 | +### Features |
| 10 | + |
| 11 | +- Simple and fairly fast. |
| 12 | +- Customization: |
| 13 | + - Grid size |
| 14 | + - Multiple axes (in any combination) |
| 15 | + - Ability to generate colliders |
| 16 | + - ... |
| 17 | +- Supports all vertex data: |
| 18 | + - Normals |
| 19 | + - Colors |
| 20 | + - Multiple uv channels |
9 | 21 | - Doesn't modify the existing mesh.
|
| 22 | +- Can be used both in editor and at runtime. |
| 23 | +- Submeshes persist when saving the scene. |
10 | 24 |
|
11 | 25 | 
|
12 | 26 |
|
13 |
| -# Installation |
14 |
| -Drag the folder containing MeshSplit.cs and Editor folder to your Assets folder. |
| 27 | +# Usage - MeshSplitController component |
| 28 | + |
| 29 | +Put the "MeshSplitController" component on the game object you want to split and press the "Create submeshes" button. Press "Clear submeshes" to revert. |
| 30 | + |
| 31 | +# Usage - API |
| 32 | + |
| 33 | +// your mesh |
| 34 | + |
| 35 | +Mesh mesh; |
| 36 | + |
| 37 | +// create a mesh splitter with some parameters (see MeshSplitParameters.cs for default settings) |
| 38 | + |
| 39 | +var meshSplitter = new MeshSplitter(new MeshSplitParameters |
| 40 | +{ |
| 41 | + GridSize = 32, |
| 42 | + GenerateColliders = true |
| 43 | +}); |
| 44 | + |
| 45 | +// create submeshes assigned to points |
15 | 46 |
|
16 |
| -# Usage |
17 |
| -Put the "Mesh Split" component on the game object you want to split and press the "Split" button. Press "Clear" to revert. |
| 47 | +var subMeshes = meshSplitter.Split(mesh); |
18 | 48 |
|
19 |
| -Requirements: |
20 |
| -- Mesh Filter component |
|
0 commit comments