Ejemplo n.º 1
0
        private static void AddCollider(MeshColliderConf colliderConf, GameObject go, LazyActionRunner lazyRunner, Collider originalCollider)
        {
            Profiler.BeginSample("AddCollider");
            UnityEngine.Object.Destroy(originalCollider);


            var action = new Action(() =>
            {
                Profiler.BeginSample("Action: AddCollider");

                var collider            = go.AddComponent <MeshCollider>();
                collider.sharedMaterial = colliderConf.Material;
                collider.sharedMesh     = colliderConf.Mesh;
                collider.inflateMesh    = true;

                var convexResult = new ConvexSetResult();
                convexResult.SetConvex(collider);

                Profiler.EndSample();
            });

            lazyRunner.AddLazyAction(action);

            Profiler.EndSample();
        }
        private static MeshCollider AddCollider(MeshColliderConf colliderConf, GameObject go)
        {
            var collider = go.AddComponent <MeshCollider>();

            collider.sharedMaterial = colliderConf.Material;
            collider.sharedMesh     = colliderConf.Mesh;
            collider.inflateMesh    = true;

            var convexResult = new ConvexSetResult();

            convexResult.SetConvex(collider);

            if (convexResult.Success)
            {
                return(collider);
            }

            UnityEngine.Object.Destroy(collider);
            return(null);
        }