2024-12-24 14:06:56 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
public class SkinedMeshCollider : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
public SkinnedMeshRenderer meshRenderer;
|
|
|
|
|
|
public MeshCollider collider;
|
2024-12-26 21:33:08 +08:00
|
|
|
|
public Mesh colliderMesh;
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
colliderMesh = new Mesh();
|
|
|
|
|
|
}
|
2024-12-24 14:06:56 +08:00
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
2024-12-26 21:33:08 +08:00
|
|
|
|
|
2024-12-24 14:06:56 +08:00
|
|
|
|
meshRenderer.BakeMesh(colliderMesh); //<2F><><EFBFBD><EFBFBD>mesh
|
|
|
|
|
|
collider.sharedMesh = null;
|
|
|
|
|
|
collider.sharedMesh = colliderMesh; //<2F><><EFBFBD>µ<EFBFBD>mesh<73><68><EFBFBD><EFBFBD>meshcollider
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|