Last active
September 19, 2016 19:04
-
-
Save sabresaurus/168f3e1f25965ff1d83a8ec4e380e7fe to your computer and use it in GitHub Desktop.
Makes generated mesh colliders compatible with SuperCharacterController (https://github.com/IronWarrior/SuperCharacterController)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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