TouchMesh() public method

public TouchMesh ( Mesh mesh ) : void
mesh Mesh
return void
        public static void Build(tk2dTileMap tileMap, bool editMode, bool forceBuild)
        {
            bool skipPrefabs = editMode?false:true;
            bool incremental = !forceBuild;
            int  numLayers   = tileMap.data.NumLayers;

            for (int layerId = 0; layerId < numLayers; ++layerId)
            {
                var layer = tileMap.Layers[layerId];
                if (layer.IsEmpty)
                {
                    continue;
                }

                var  layerData = tileMap.data.Layers[layerId];
                bool useColor  = !tileMap.ColorChannel.IsEmpty && tileMap.data.Layers[layerId].useColor;

                for (int cellY = 0; cellY < layer.numRows; ++cellY)
                {
                    int baseY = cellY * layer.divY;
                    for (int cellX = 0; cellX < layer.numColumns; ++cellX)
                    {
                        int baseX = cellX * layer.divX;
                        var chunk = layer.GetChunk(cellX, cellY);

                        ColorChunk colorChunk = tileMap.ColorChannel.GetChunk(cellX, cellY);

                        bool colorChunkDirty = (colorChunk != null) && colorChunk.Dirty;
                        if (incremental && !colorChunkDirty && !chunk.Dirty)
                        {
                            continue;
                        }

                        if (chunk.mesh != null)
                        {
                            chunk.mesh.Clear();
                        }

                        if (chunk.IsEmpty)
                        {
                            continue;
                        }

                        if (editMode ||
                            (!editMode && !layerData.skipMeshGeneration))
                        {
                            BuildForChunk(tileMap, chunk, colorChunk, useColor, skipPrefabs, baseX, baseY);
                        }

                        if (chunk.mesh != null)
                        {
                            tileMap.TouchMesh(chunk.mesh);
                        }
                    }
                }
            }
        }
 public static void Build(tk2dTileMap tileMap, bool editMode, bool forceBuild)
 {
     bool skipPrefabs = !editMode;
     bool flag2 = !forceBuild;
     int numLayers = tileMap.data.NumLayers;
     for (int i = 0; i < numLayers; i++)
     {
         Layer layer = tileMap.Layers[i];
         if (!layer.IsEmpty)
         {
             LayerInfo info = tileMap.data.Layers[i];
             bool useColor = !tileMap.ColorChannel.IsEmpty && tileMap.data.Layers[i].useColor;
             bool useSortingLayers = tileMap.data.useSortingLayers;
             for (int j = 0; j < layer.numRows; j++)
             {
                 int baseY = j * layer.divY;
                 for (int k = 0; k < layer.numColumns; k++)
                 {
                     int baseX = k * layer.divX;
                     SpriteChunk chunk = layer.GetChunk(k, j);
                     ColorChunk colorChunk = tileMap.ColorChannel.GetChunk(k, j);
                     bool flag5 = (colorChunk != null) && colorChunk.Dirty;
                     if ((!flag2 || flag5) || chunk.Dirty)
                     {
                         if (chunk.mesh != null)
                         {
                             chunk.mesh.Clear();
                         }
                         if (!chunk.IsEmpty)
                         {
                             if (editMode || (!editMode && !info.skipMeshGeneration))
                             {
                                 BuildForChunk(tileMap, chunk, colorChunk, useColor, skipPrefabs, baseX, baseY);
                                 if ((chunk.gameObject != null) && useSortingLayers)
                                 {
                                     Renderer renderer = chunk.gameObject.renderer;
                                     if (renderer != null)
                                     {
                                         renderer.sortingLayerName = info.sortingLayerName;
                                         renderer.sortingOrder = info.sortingOrder;
                                     }
                                 }
                             }
                             if (chunk.mesh != null)
                             {
                                 tileMap.TouchMesh(chunk.mesh);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        public static void Build(tk2dTileMap tileMap, bool editMode, bool forceBuild)
        {
            bool skipPrefabs = editMode?false:true;
            bool incremental = !forceBuild;
            int numLayers = tileMap.data.NumLayers;

            for (int layerId = 0; layerId < numLayers; ++layerId)
            {
                var layer = tileMap.Layers[layerId];
                if (layer.IsEmpty)
                    continue;

                var layerData = tileMap.data.Layers[layerId];
                bool useColor = !tileMap.ColorChannel.IsEmpty && tileMap.data.Layers[layerId].useColor;

                for (int cellY = 0; cellY < layer.numRows; ++cellY)
                {
                    int baseY = cellY * layer.divY;
                    for (int cellX = 0; cellX < layer.numColumns; ++cellX)
                    {
                        int baseX = cellX * layer.divX;
                        var chunk = layer.GetChunk(cellX, cellY);

                        ColorChunk colorChunk = tileMap.ColorChannel.GetChunk(cellX, cellY);

                        bool colorChunkDirty = (colorChunk != null) && colorChunk.Dirty;
                        if (incremental && !colorChunkDirty && !chunk.Dirty)
                            continue;

                        if (chunk.mesh != null)
                            chunk.mesh.Clear();

                        if (chunk.IsEmpty)
                            continue;

                        if (editMode ||
                            (!editMode && !layerData.skipMeshGeneration))
                            BuildForChunk(tileMap, chunk, colorChunk, useColor, skipPrefabs, baseX, baseY);

                        if (chunk.mesh != null)
                            tileMap.TouchMesh(chunk.mesh);
                    }
                }
            }
        }
Example #4
0
        public static void Build(tk2dTileMap tileMap, bool editMode, bool forceBuild)
        {
            bool skipPrefabs = editMode?false:true;
            bool incremental = !forceBuild;
            int  numLayers   = tileMap.data.NumLayers;

            for (int layerId = 0; layerId < numLayers; ++layerId)
            {
                var layer = tileMap.Layers[layerId];
                if (layer.IsEmpty)
                {
                    continue;
                }

                var  layerData = tileMap.data.Layers[layerId];
                bool useColor  = !tileMap.ColorChannel.IsEmpty && tileMap.data.Layers[layerId].useColor;
#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
                bool useSortingLayer = tileMap.data.useSortingLayers;
#endif

                for (int cellY = 0; cellY < layer.numRows; ++cellY)
                {
                    int baseY = cellY * layer.divY;
                    for (int cellX = 0; cellX < layer.numColumns; ++cellX)
                    {
                        int baseX = cellX * layer.divX;
                        var chunk = layer.GetChunk(cellX, cellY);

                        ColorChunk colorChunk = tileMap.ColorChannel.GetChunk(cellX, cellY);

                        bool colorChunkDirty = (colorChunk != null) && colorChunk.Dirty;
                        if (incremental && !colorChunkDirty && !chunk.Dirty)
                        {
                            continue;
                        }

                        if (chunk.mesh != null)
                        {
                            chunk.mesh.Clear();
                        }

                        if (chunk.IsEmpty)
                        {
                            continue;
                        }

                        if (editMode ||
                            (!editMode && !layerData.skipMeshGeneration))
                        {
                            BuildForChunk(tileMap, chunk, colorChunk, useColor, skipPrefabs, baseX, baseY);

#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
                            if (chunk.gameObject != null && useSortingLayer)
                            {
                                Renderer r = chunk.gameObject.GetComponent <Renderer>();
                                if (r != null)
                                {
                                    r.sortingLayerName = layerData.sortingLayerName;
                                    r.sortingOrder     = layerData.sortingOrder;
                                }
                            }
#endif
                        }

                        if (chunk.mesh != null)
                        {
                            tileMap.TouchMesh(chunk.mesh);
                        }
                    }
                }
            }
        }
		public static void Build(tk2dTileMap tileMap, bool editMode, bool forceBuild)
		{
			bool skipPrefabs = editMode?false:true;
			bool incremental = !forceBuild;
			int numLayers = tileMap.data.NumLayers;
			
			for (int layerId = 0; layerId < numLayers; ++layerId)
			{
				var layer = tileMap.Layers[layerId];
				if (layer.IsEmpty)
					continue;

				var layerData = tileMap.data.Layers[layerId];
				bool useColor = !tileMap.ColorChannel.IsEmpty && tileMap.data.Layers[layerId].useColor;
#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
				bool useSortingLayer = tileMap.data.useSortingLayers;
#endif
	
				for (int cellY = 0; cellY < layer.numRows; ++cellY)
				{
					int baseY = cellY * layer.divY;
					for (int cellX = 0; cellX < layer.numColumns; ++cellX)
					{
						int baseX = cellX * layer.divX;
						var chunk = layer.GetChunk(cellX, cellY);
						
						ColorChunk colorChunk = tileMap.ColorChannel.GetChunk(cellX, cellY);
						
						bool colorChunkDirty = (colorChunk != null) && colorChunk.Dirty;
						if (incremental && !colorChunkDirty && !chunk.Dirty)
							continue;
						
						if (chunk.mesh != null)
							chunk.mesh.Clear();
						
						if (chunk.IsEmpty)
							continue;
						
						if (editMode ||
							(!editMode && !layerData.skipMeshGeneration)) {
							BuildForChunk(tileMap, chunk, colorChunk, useColor, skipPrefabs, baseX, baseY);

#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
							if (chunk.gameObject != null && useSortingLayer) {
								Renderer r = chunk.gameObject.renderer;
								if (r != null) {
									r.sortingLayerName = layerData.sortingLayerName;
									r.sortingOrder = layerData.sortingOrder;
								}
							}
#endif
						}
						
						if (chunk.mesh != null)
							tileMap.TouchMesh(chunk.mesh);
					}
				}
			}
		}