Пример #1
0
        private void AddMeshComponents()
        {
            if (meshFilter == null)
            {
                meshFilter = MeshObject.AddComponent <MeshFilter>();
            }

            if (PlaneType == Plane.Top)
            {
                if (settings.DrawTopMeshRenderer)
                {
                    if (meshRenderer == null)
                    {
                        meshRenderer = MeshObject.AddComponent <MeshRenderer> ();
                    }
                }
                if (settings.DrawTopMeshCollider)
                {
                    if (meshCollider == null)
                    {
                        meshCollider = MeshObject.AddComponent <MeshCollider> ();
                    }
                }
            }
            else if (PlaneType == Plane.Front)
            {
                if (meshRenderer == null)
                {
                    meshRenderer = MeshObject.AddComponent <MeshRenderer>();
                }
                if (polyCollider == null)
                {
                    polyCollider = MeshObject.AddComponent <PolygonCollider2D> ();
                }
            }
            else
            {
                if (meshRenderer == null)
                {
                    meshRenderer = MeshObject.AddComponent <MeshRenderer>();
                }
                if (meshCollider == null)
                {
                    meshCollider = MeshObject.AddComponent <MeshCollider>();
                }
            }

            GameObject.DestroyImmediate(meshFilter.sharedMesh);
            meshFilter.sharedMesh = new Mesh();
            mesh = meshFilter.sharedMesh;

            // mesh = meshFilter.mesh;
        }
Пример #2
0
        private void AddMeshComponents()
        {
            if (meshFilter == null)
            {
                meshFilter = MeshObject.AddComponent <MeshFilter>();
            }

            if (PlaneType == Plane.Top)
            {
                if (settings.DrawTopMeshRenderer)
                {
                    if (meshRenderer == null)
                    {
                        meshRenderer = MeshObject.AddComponent <MeshRenderer>();
                    }
                }
                if (settings.DrawTopMeshCollider)
                {
                    if (meshCollider == null)
                    {
                        meshCollider = MeshObject.AddComponent <MeshCollider>();
                    }
                }
            }
            else//this is the side
            {
                if (meshRenderer == null)
                {
                    meshRenderer = MeshObject.AddComponent <MeshRenderer>();
                }
                if (meshCollider == null)
                {
                    meshCollider = MeshObject.AddComponent <MeshCollider>();
                }

                //add planes to sides so vehicles can't run off road
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.name             = "SidePlane_R";
                plane.transform.parent = MeshObject.transform;

                GameObject planeL = GameObject.CreatePrimitive(PrimitiveType.Plane);
                planeL.name             = "SidePlane_L";
                planeL.transform.parent = MeshObject.transform;
            }

            GameObject.DestroyImmediate(meshFilter.sharedMesh);
            meshFilter.sharedMesh = new Mesh();
            mesh = meshFilter.sharedMesh;

            // mesh = meshFilter.mesh;
        }
Пример #3
0
        private void AddMeshComponents()
        {
            if (meshFilter == null)
            {
                meshFilter = MeshObject.AddComponent <MeshFilter>();
            }

            if (PlaneType == Plane.Top)
            {
                if (settings.DrawTopMeshRenderer)
                {
                    if (meshRenderer == null)
                    {
                        meshRenderer = MeshObject.AddComponent <MeshRenderer>();
                    }
                }
                if (settings.DrawTopMeshCollider)
                {
                    if (meshCollider == null)
                    {
                        meshCollider = MeshObject.AddComponent <MeshCollider>();
                    }
                }
            }
            else
            {
                if (meshRenderer == null)
                {
                    meshRenderer = MeshObject.AddComponent <MeshRenderer>();
                }
                if (meshCollider == null)
                {
                    meshCollider          = MeshObject.AddComponent <MeshCollider>();
                    meshCollider.material = new PhysicMaterial();
                }
            }

            GameObject.DestroyImmediate(meshFilter.sharedMesh);
            meshFilter.sharedMesh = new Mesh();
            mesh = meshFilter.sharedMesh;

            // mesh = meshFilter.mesh;
        }