Ejemplo n.º 1
0
 private static void AddMesh(Entity e, Resource.Mesh mesh, Resource.Mat material)
 {
     m.AddComponentData(e, new C_HasMesh
     {
         mesh     = mesh,
         material = material,
         UV       = new float4(1f, 1f, 0f, 0f),
         color    = Color.white
     });
 }
Ejemplo n.º 2
0
    private static PhysicsCollider CreateMeshCollider(Resource.Mesh mesh, float3 scale, CollisionFilter filter, PhysicsMaterial physicsMaterial)
    {
        UnityEngine.Vector3[] v3Verts = Resource.GetMesh(mesh).vertices;
        float3[] float3Verts          = new float3[v3Verts.Length];
        for (int i = 0; i < v3Verts.Length; i++)
        {
            float3Verts[i] = v3Verts[i] * scale;
        }
        NativeArray <float3> nativeVerts = new NativeArray <float3>(float3Verts, Allocator.Temp);

        return(new PhysicsCollider {
            Value = ConvexCollider.Create(nativeVerts, ConvexHullGenerationParameters.Default, filter, physicsMaterial)
        });
    }