clear() public method

public clear ( ) : void
return void
Exemplo n.º 1
0
        public GameObject[] generateColliders()
        {
            GameObject[] colliders = new GameObject[faces];

            float anglePerFace = 360f / (float)faces;
            float start        = 0;
            float end          = start + anglePerFace;
            float thickness    = topRadius - topInnerRadius;

            Mesh         mesh;
            MeshFilter   mf;
            MeshCollider mc;
            MeshBuilder  builder = new MeshBuilder();

            GameObject collider;

            for (int i = 0; i < faces; i++)
            {
                collider     = new GameObject("ProceduralCylinderCollider-" + i);
                colliders[i] = collider;
                start        = (float)i * anglePerFace;
                end          = start + anglePerFace;
                builder.generatePanelCollider(offset, start, end, 0, height, bottomRadius, topRadius, thickness);
                mesh          = builder.buildMesh();
                mf            = collider.AddComponent <MeshFilter>();
                mf.mesh       = mesh;
                mc            = collider.AddComponent <MeshCollider>();
                mc.sharedMesh = mesh;
                mc.convex     = true;
                builder.clear();
            }
            return(colliders);
        }
Exemplo n.º 2
0
        public GameObject[] generateColliders(Vector3 center, int facesPerCollider)
        {
            float totalAngle   = endAngle - startAngle;
            float anglePerFace = 360f / (float)faces;
            int   localFaces   = (int)Math.Round(totalAngle / anglePerFace);

            localFaces /= facesPerCollider;
            GameObject[] colliders = new GameObject[localFaces * (innerArcs.Count - 1)];
            float        localStart, localEnd, startY, height, topRadius, bottomRadius, thickness;
            Mesh         colliderMesh;
            MeshFilter   mf;
            //MeshRenderer mr;
            MeshCollider mc;

            thickness = outerArcs[0].radius - innerArcs[0].radius;
            MeshBuilder builder       = new MeshBuilder();
            int         colliderIndex = 0;

            for (int i = 0; i < localFaces; i++)
            {
                localStart = startAngle + (float)i * anglePerFace;
                localEnd   = localStart + (anglePerFace * facesPerCollider);
                for (int k = 0; k < innerArcs.Count - 1; k++, colliderIndex++)
                {
                    startY       = innerArcs[k].height;
                    height       = innerArcs[k + 1].height - startY;
                    bottomRadius = outerArcs[k].radius;
                    topRadius    = outerArcs[k + 1].radius;
                    builder.generatePanelCollider(center, localStart, localEnd, startY, height, bottomRadius, topRadius, thickness);
                    colliderMesh = builder.buildMesh();
                    builder.clear();
                    colliders[colliderIndex] = new GameObject("PanelCollider" + i + "-" + k);
                    mf = colliders[colliderIndex].AddComponent <MeshFilter>();
                    //mr = colliders[i].AddComponent<MeshRenderer>();
                    mc      = colliders[colliderIndex].AddComponent <MeshCollider>();
                    mf.mesh = colliderMesh;
                    //mr.enabled = true;
                    mc.sharedMesh = colliderMesh;
                    mc.enabled    = mc.convex = true;
                }
            }
            return(colliders);
        }
Exemplo n.º 3
0
 public GameObject[] generateColliders(Vector3 center, int facesPerCollider)
 {
     float totalAngle = endAngle - startAngle;
     float anglePerFace = 360f / (float)faces;
     int localFaces = (int)Math.Round(totalAngle / anglePerFace);
     localFaces /= facesPerCollider;
     GameObject[] colliders = new GameObject[localFaces];
     float localStart, localEnd, startY, height, topRadius, bottomRadius, thickness;
     Mesh colliderMesh;
     MeshFilter mf;
     //MeshRenderer mr;
     MeshCollider mc;
     thickness = outerArcs[0].radius - innerArcs[0].radius;
     MeshBuilder builder = new MeshBuilder();
     for (int i = 0; i < localFaces; i++)
     {
         localStart = startAngle + (float)i * anglePerFace;
         localEnd = localStart + (anglePerFace * facesPerCollider);
         for (int k = 0; k < innerArcs.Count - 1; k++)
         {
             startY = innerArcs[k].height;
             height = innerArcs[k+1].height - startY;
             bottomRadius = outerArcs[k].radius;
             topRadius = outerArcs[k+1].radius;
             builder.generatePanelCollider(center, localStart, localEnd, startY, height, bottomRadius, topRadius, thickness);
             colliderMesh = builder.buildMesh();
             builder.clear();
             colliders[i] = new GameObject("PanelCollider"+i+"-"+k);
             mf = colliders[i].AddComponent<MeshFilter>();
             //mr = colliders[i].AddComponent<MeshRenderer>();
             mc = colliders[i].AddComponent<MeshCollider>();
             mf.mesh = colliderMesh;
             //mr.enabled = true;
             mc.sharedMesh = colliderMesh;
             mc.enabled = mc.convex = true;
         }
     }
     return colliders;
 }
Exemplo n.º 4
0
        public GameObject[] generateColliders()
        {
            GameObject[] colliders = new GameObject[faces];

            float anglePerFace = 360f / (float)faces;
            float start = 0;
            float end = start + anglePerFace;
            float thickness = topRadius - topInnerRadius;

            Mesh mesh;
            MeshFilter mf;
            MeshCollider mc;
            MeshBuilder builder = new MeshBuilder();

            GameObject collider;
            for (int i = 0; i < faces; i++)
            {
                collider = new GameObject("ProceduralCylinderCollider-" + i);
                colliders[i] = collider;
                start = (float)i * anglePerFace;
                end = start + anglePerFace;
                builder.generatePanelCollider(offset, start, end, 0, height, bottomRadius, topRadius, thickness);
                mesh = builder.buildMesh();
                mf = collider.AddComponent<MeshFilter>();
                mf.mesh = mesh;
                mc = collider.AddComponent<MeshCollider>();
                mc.sharedMesh = mesh;
                mc.convex = true;
                builder.clear();
            }
            return colliders;
        }