Skip to content

Instantly share code, notes, and snippets.

@sabresaurus
Last active September 19, 2016 19:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sabresaurus/168f3e1f25965ff1d83a8ec4e380e7fe to your computer and use it in GitHub Desktop.
Save sabresaurus/168f3e1f25965ff1d83a8ec4e380e7fe to your computer and use it in GitHub Desktop.
Makes generated mesh colliders compatible with SuperCharacterController (https://github.com/IronWarrior/SuperCharacterController)
#if UNITY_EDITOR
using UnityEngine;
using Sabresaurus.SabreCSG;
public static class BSPTreePostProcess
{
[PostProcessCSGBuild]
public static void OnPostProcessCSGBuild(Transform meshGroup)
{
if(meshGroup != null)
{
// Grab all the built mesh colliders
MeshCollider[] colliders = meshGroup.GetComponentsInChildren<MeshCollider>();
// Add a SuperCharacterController BSPTree to each collider
for (int i = 0; i < colliders.Length; i++)
{
colliders[i].gameObject.AddComponent<BSPTree>();
}
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment