private ChiselColliderComponents CreateColliderComponents(ChiselModel model, GeneratedMeshDescription meshDescription) { var gameObject = CreateComponentGameObject(model, GeneratedMeshColliderName, typeof(MeshCollider)); var colliderComponents = new ChiselColliderComponents { meshCollider = gameObject.GetComponent <MeshCollider>(), gameObject = gameObject, transform = gameObject.transform }; return(colliderComponents); }
// NOTE: assumes that if a meshCollider is passed to this, it is -valid- // do any checking outside of this method, and make sure everything that // needs to be cleaned up, IS cleaned up private bool UpdateOrCreateColliderComponents(ChiselModel model, ModelState modelState, GeneratedMeshDescription meshDescription, ref ChiselColliderComponents colliderComponents) { bool updated = false; if (colliderComponents == null) { colliderComponents = CreateColliderComponents(model, meshDescription); updated = true; } UpdateColliderComponents(model, modelState, meshDescription, colliderComponents); UpdateComponentFlags(model, modelState, colliderComponents.meshCollider, colliderComponents.gameObject, colliderComponents.transform, GeneratedMeshColliderName, notEditable: true); if (!colliderComponents.meshCollider.enabled) { colliderComponents.meshCollider.enabled = true; } return(updated); }
private void UpdateColliderComponents(ChiselModel model, ModelState modelState, GeneratedMeshDescription meshDescription, ChiselColliderComponents colliderComponents) { var meshCollider = colliderComponents.meshCollider; updateMeshColliders.Add(meshCollider); }