DestroyMesh() public method

public DestroyMesh ( Mesh mesh ) : void
mesh Mesh
return void
 public void DestroyColliderData(tk2dTileMap tileMap)
 {
     if (this.colliderMesh != null)
     {
         tileMap.DestroyMesh(this.colliderMesh);
     }
     if (((this.meshCollider != null) && (this.meshCollider.sharedMesh != null)) && (this.meshCollider.sharedMesh != this.colliderMesh))
     {
         tileMap.DestroyMesh(this.meshCollider.sharedMesh);
     }
     if (this.meshCollider != null)
     {
         tk2dUtil.DestroyImmediate(this.meshCollider);
     }
     this.meshCollider = null;
     this.colliderMesh = null;
     if (this.edgeColliders.Count > 0)
     {
         for (int i = 0; i < this.edgeColliders.Count; i++)
         {
             tk2dUtil.DestroyImmediate(this.edgeColliders[i]);
         }
         this.edgeColliders.Clear();
     }
 }
示例#2
0
		public void DestroyColliderData(tk2dTileMap tileMap)
		{
			if (colliderMesh != null) 
				tileMap.DestroyMesh(colliderMesh);
			if (meshCollider != null && meshCollider.sharedMesh != null && meshCollider.sharedMesh != colliderMesh) 
				tileMap.DestroyMesh(meshCollider.sharedMesh);
			if (meshCollider != null) GameObject.DestroyImmediate(meshCollider);
			meshCollider = null;
			colliderMesh = null;
		}
示例#3
0
		public void DestroyColliderData(tk2dTileMap tileMap)
		{
			if (colliderMesh != null) 
				tileMap.DestroyMesh(colliderMesh);
			if (meshCollider != null && meshCollider.sharedMesh != null && meshCollider.sharedMesh != colliderMesh) 
				tileMap.DestroyMesh(meshCollider.sharedMesh);
			if (meshCollider != null) GameObject.DestroyImmediate(meshCollider);
			meshCollider = null;
			colliderMesh = null;
		}
示例#4
0
        /// Deletes all generated instances
        public static void CleanRenderData(tk2dTileMap tileMap)
        {
            if (tileMap.renderData == null)
            {
                return;
            }

            // Build a list of all children
            // All children will appear after the parent
            int currentProcessedChild = 0;
            List <Transform> children = new List <Transform>();

            children.Add(tileMap.renderData.transform);
            while (currentProcessedChild < children.Count)
            {
                var thisChild  = children[currentProcessedChild++];
                int childCount = thisChild.childCount;
                for (int i = 0; i < childCount; ++i)
                {
                    children.Add(thisChild.GetChild(i));
                }
            }
            currentProcessedChild = children.Count - 1;
            while (currentProcessedChild > 0)             // skip very first as it is the root object
            {
                var go = children[currentProcessedChild--].gameObject;

                MeshFilter mf = go.GetComponent <MeshFilter>();
                if (mf != null)
                {
                    Mesh mesh = mf.sharedMesh;
                    mf.sharedMesh = null;

                    tileMap.DestroyMesh(mesh);
                }

                MeshCollider meshCollider = go.GetComponent <MeshCollider>();
                if (meshCollider)
                {
                    Mesh mesh = meshCollider.sharedMesh;
                    meshCollider.sharedMesh = null;

                    tileMap.DestroyMesh(mesh);
                }

                GameObject.DestroyImmediate(go);
            }

            tileMap.buildKey++;             // force a rebuild
        }
        /// Deletes all generated instances
        public static void CleanRenderData(tk2dTileMap tileMap)
        {
            if (tileMap.renderData == null)
                return;

            // Build a list of all children
            // All children will appear after the parent
            int currentProcessedChild = 0;
            List<Transform> children = new List<Transform>();
            children.Add(tileMap.renderData.transform);
            while (currentProcessedChild < children.Count)
            {
                var thisChild = children[currentProcessedChild++];
                int childCount = thisChild.GetChildCount();
                for (int i = 0; i < childCount; ++i)
                    children.Add(thisChild.GetChild(i));
            }
            currentProcessedChild = children.Count - 1;
            while (currentProcessedChild > 0) // skip very first as it is the root object
            {
                var go = children[currentProcessedChild--].gameObject;

                MeshFilter mf = go.GetComponent<MeshFilter>();
                if (mf != null)
                {
                    Mesh mesh = mf.sharedMesh;
                    mf.sharedMesh = null;

                    tileMap.DestroyMesh(mesh);
                }

                MeshCollider meshCollider = go.GetComponent<MeshCollider>();
                if (meshCollider)
                {
                    Mesh mesh = meshCollider.sharedMesh;
                    meshCollider.sharedMesh = null;

                    tileMap.DestroyMesh(mesh);
                }

                GameObject.DestroyImmediate(go);
            }

            tileMap.buildKey++; // force a rebuild
        }
示例#6
0
		public void DestroyGameData(tk2dTileMap tileMap)
		{
			if (mesh != null) tileMap.DestroyMesh(mesh);
			if (gameObject != null) GameObject.DestroyImmediate(gameObject);
			gameObject = null;
			mesh = null;
			
			DestroyColliderData(tileMap);
		}
示例#7
0
		public void DestroyGameData(tk2dTileMap tileMap)
		{
			if (mesh != null) tileMap.DestroyMesh(mesh);
			if (gameObject != null) GameObject.DestroyImmediate(gameObject);
			gameObject = null;
			mesh = null;
			
			DestroyColliderData(tileMap);
		}
 public void DestroyGameData(tk2dTileMap tileMap)
 {
     if (this.mesh != null)
     {
         tileMap.DestroyMesh(this.mesh);
     }
     if (this.gameObject != null)
     {
         tk2dUtil.DestroyImmediate(this.gameObject);
     }
     this.gameObject = null;
     this.mesh = null;
     this.DestroyColliderData(tileMap);
 }
        /// Deletes all generated instances
        public static void CleanRenderData(tk2dTileMap tileMap)
        {
            if (tileMap.renderData == null)
                return;

            // To Do: Move all prefabs to the "Prefabs" object. (Then don't add to children list)

            // Build a list of all children
            // All children will appear after the parent
            int currentProcessedChild = 0;
            List<Transform> children = new List<Transform>();
            children.Add(tileMap.renderData.transform);
            while (currentProcessedChild < children.Count)
            {
                var thisChild = children[currentProcessedChild++];
                int childCount = thisChild.childCount;
                for (int i = 0; i < childCount; ++i)
                    children.Add(thisChild.GetChild(i));
            }
            currentProcessedChild = children.Count - 1;
            while (currentProcessedChild > 0) // skip very first as it is the root object
            {
                var go = children[currentProcessedChild--].gameObject;

                MeshFilter mf = go.GetComponent<MeshFilter>();
                if (mf != null)
                {
                    if (mf.sharedMesh != null && !EditorUtility.IsPersistent(mf.sharedMesh))
                    {
                        Mesh mesh = mf.sharedMesh;
                        mf.sharedMesh = null;
                        tileMap.DestroyMesh(mesh);
                    }
                }

                MeshCollider meshCollider = go.GetComponent<MeshCollider>();
                if (meshCollider)
                {
                    if (meshCollider.sharedMesh != null && !EditorUtility.IsPersistent(meshCollider.sharedMesh))
                    {
                        Mesh mesh = meshCollider.sharedMesh;
                        meshCollider.sharedMesh = null;
                        tileMap.DestroyMesh(mesh);
                    }
                }

                GameObject.DestroyImmediate(go);
            }
        }