public void CreatePaddedMesh(Renderer[] modelRenderers)
 {
     renderers = new Renderer[modelRenderers.Length];
     for (int i = 0; i < modelRenderers.Length; i++)
     {
         Mesh mesh;
         if (modelRenderers[i] is SkinnedMeshRenderer)
         {
             mesh = new Mesh();
             (modelRenderers[i] as SkinnedMeshRenderer).BakeMesh(mesh);
         }
         else
         {
             mesh = modelRenderers[i].GetComponent <MeshFilter>().sharedMesh;
         }
         mesh = BuildPaddedMesh.GeneratePadded(mesh, 0.00390625f);
         GameObject gameObject = new GameObject("UnwrapMesh");
         gameObject.transform.SetParent(modelRenderers[i].transform, worldPositionStays: false);
         gameObject.layer = 31;
         gameObject.AddComponent <MeshFilter>().sharedMesh = mesh;
         renderers[i]         = gameObject.AddComponent <MeshRenderer>();
         renderers[i].enabled = false;
     }
 }
Пример #2
0
 private void Start()
 {
     GetComponent <MeshFilter>().sharedMesh = BuildPaddedMesh.GeneratePadded(GetComponent <MeshFilter>().sharedMesh, 0.1f);
 }