StaticObjectCombiner
A class in Root.Township, the global namespace.
Bake-time tool on static prefabs that merges LOD groups, joins meshes by material, removes hidden or underground triangles and flattens colliders, based on its functions flags. Runs during static batching, not in a live game.
- Listed in Global namespace: S
- Inherits or implements
MonoBehaviour - Derived types
DynamicObjectCombiner,SceneStaticObjectCombiner - Nested types
CombineFunctions,IncrementalMesh,Space - Documented in Static objects
Constructors
| Member | What it is |
|---|---|
StaticObjectCombiner() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected StaticObjectCombiner.CombineFunctions functions | Flags for which bake steps to run (LOD join, mesh join, occlusion, collider joining and flattening, terrain occlusion). |
7 private and internal fields
Properties
Events
Methods
| Member | What it is |
|---|---|
static void AutoLOD(GameObject baseObject) | Merges all child LOD groups into a single LOD group on the base object, taking the largest transition height per level. |
virtual void Bake() | Runs every enabled bake step on this object. |
static bool CleanRecursive(Transform parent) | Deletes child objects that have nothing but a transform. True if the given object was deleted. |
static Mesh ExcludeOccludedTriangles(Mesh mesh, List<RemovingTriangle> trianglesToRemove) | Returns a copy of a mesh with the listed triangles removed. |
static void FlattenPrimitiveColliders(Transform transform) | Moves box colliders onto shared child objects grouped by layer and rotation, so there are fewer collider objects. |
static void GatherRenderers(GameObject prefab, LODGroup lodGroup, Dictionary<MaterialLOD, List<MeshFilter>> meshesByMaterial, Func<Renderer, bool> validateRenderer = null) | Groups the prefab's mesh filters by material and LOD level, skipping impostors and parts on other rigidbodies. |
static List<GameObject> JoinMeshes(Transform baseTransform, LODGroup lodGroup, KeyValuePair<MaterialLOD, List<MeshFilter>> pair, out List<Mesh> newMeshes, bool isCleaningUp = false) | Combines a group of meshes with the same material and LOD into new mesh objects under the base transform. |
void SetupFull() | Turns on every bake step. |
protected virtual bool ValidateRenderer(Renderer renderer) | Subclass filter for which renderers may be joined. Allows all by default. |
10 private and internal methods
| Member | What it is |
|---|---|
private IEnumerable<Vector3> AdditionalCheckPoints() (iterator) | Yields additionalCheckPoints in world space, as extra view points for the triangle occlusion check. |
private static bool AnyChecks(bool[] checks, List<int> triangles, int i) | True when all three vertices of a triangle passed the check (the name says any, the code needs all). |
private static int GetLODLevel(Renderer renderer, LOD[] lods) | Returns which LOD level of the group a renderer is in, or -1. |
private static void GetMesh(List<Vector3> vertices, List<int> triangles, ref bool needsNormal, List<Vector3> normals, ref bool needsTangents, List<Vector4> tangents, ref bool needsUV, List<Vector2> uv, ref bool needsUV2, List<Vector4> uv2, ref bool needsUV3, List<Vector4> uv3, ref bool needsUV4, List<Vector4> uv4, ref bool needsColor, List<Color> colors, MaterialLOD materialLOD, List<Mesh> meshes, bool hasLOD, int finalLayer, List<GameObject> result, Transform baseTransform, List<Renderer> joinedRenderers) | Builds a mesh from the gathered vertex lists, clears them, and adds a renderer object for it under the base transform. |
private static StaticObjectCombiner.Space GetNewParent(int layer, List<StaticObjectCombiner.Space> spaces, Quaternion rotation, Transform parent) | Creates a new collider parent Space for a layer and rotation and adds it to the list. |
private bool IsValidateTerrain(Object terrain) | True when a terrain exists, terrain baking isn't locked and TerrainOccludesTriangles is set. |
private void JoinMeshColliders() | Merges child mesh colliders into one collision mesh per layer, strips occluded triangles and destroys the originals. |
private void OnDrawGizmosSelected() | Empty. |
private static bool TriangleValidation(Vector3 a, Vector3 b, Vector3 c, Matrix4x4 localToWorld, Terrain terrain) | True when any edge of the triangle crosses the terrain (temporarily moved to layer 3 for the linecast). |
private static bool Validation(Vector3 worldVertex, Matrix4x4 localToWorld, Terrain terrain) | True when a vertex is above the terrain height at its position. |