public void Pack()
        {
            _opaqueTilePackTexture = new PackTexture(WorldTextureType.OpaqueTileTex, PicSize, PicSize, TextureFormat.ETC_RGB4, true);
            PackTexture(_opaqueTilePackTexture, _pathMap[WorldTextureType.OpaqueTileTex], WorldTextureType.OpaqueTileTex);

            _opaqueNoTilePackTexture = new PackTexture(WorldTextureType.OpaqueNoTileTex, PicSize, PicSize, TextureFormat.DXT1);
            PackTexture(_opaqueNoTilePackTexture, _pathMap[WorldTextureType.OpaqueNoTileTex], WorldTextureType.OpaqueNoTileTex);

            _transparentTilePackTexture = new PackTexture(WorldTextureType.TransparentTileTex, PicSize, PicSize, TextureFormat.DXT5, true);
            PackTexture(_transparentTilePackTexture, _pathMap[WorldTextureType.TransparentTileTex], WorldTextureType.TransparentTileTex);

            _transparentNoTilePackTexture = new PackTexture(WorldTextureType.TransparentNoTileTex, PicSize, PicSize, TextureFormat.DXT5);
            PackTexture(_transparentNoTilePackTexture, _pathMap[WorldTextureType.TransparentNoTileTex], WorldTextureType.TransparentNoTileTex);

            Resources.UnloadUnusedAssets();
            IsCanUseProvider = true;
        }
        public Rect GetBlockTextureRect(BlockType type, byte extendId, Direction direction)
        {
            int id    = (((int)type) << 4) + (extendId & 15);
            int idKey = GetIdKey(id, direction);
            int index = GetIdKeyIndex(idKey);

            if (index == -1)
            {
                throw new Exception("不存在类型为" + type + "拓展id为:" + extendId + "并且方向为" + direction + "的图集");
            }
            int         picKey      = _picKeyList[index];
            PackTexture packTexture = _listPackTexture[index];

            return(packTexture.GetSubTextureUV(picKey));
//			if(_worldTexMap.ContainsKey(id) && _worldTexMap[id].ContainsKey(direction))
//			{
//				string name = _worldTexMap[id][direction];
//				PackTexture packTexture = _packTextureMap[_idToTextureTypeMap[id]];
//				return packTexture.GetSubTextureUV(name);
//			}
//			throw new Exception("不存在类型为"+type + "拓展id为:" + extendId + "并且方向为" + direction);
        }
        private void PackTexture(PackTexture packTexture, string path, WorldTextureType type)
        {
            var gameObjects  = Resources.LoadAll <Texture2D>(path);
            int picExtendKey = 0;

            foreach (var item in gameObjects)
            {
                string[] result = item.name.Split('_');
                if (result.Length <= 3)
                {
                    continue;
                }
                string[] idResult = result[2].Split('-');
                int      id       = (Convert.ToInt32(idResult[0]) << 4);
                if (idResult.Length == 2)
                {
                    id += (Convert.ToInt32(idResult[1]) & 15);
                }

                int packTextureKey = GetPackTextureKey(id, picExtendKey);
                packTexture.AddTexture(item, packTextureKey);
                if (!_idToTextureTypeMap.ContainsKey(id))
                {
                    _idToTextureTypeMap.Add(id, type);
                }
                for (int i = 3; i < result.Length; i++)
                {
                    switch (result[i])
                    {
                    case "up":
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.up, packTextureKey, packTexture);
                        break;

                    case "down":
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.down, packTextureKey, packTexture);
                        break;

                    case "left":
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.left, packTextureKey, packTexture);
                        break;

                    case "right":
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.right, packTextureKey, packTexture);
                        break;

                    case "front":
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.front, packTextureKey, packTexture);
                        break;

                    case "back":
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.back, packTextureKey, packTexture);
                        break;

                    case "all":
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.up, packTextureKey, packTexture);
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.down, packTextureKey, packTexture);
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.left, packTextureKey, packTexture);
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.right, packTextureKey, packTexture);
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.front, packTextureKey, packTexture);
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.back, packTextureKey, packTexture);
                        break;

                    case "side":
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.left, packTextureKey, packTexture);
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.right, packTextureKey, packTexture);
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.front, packTextureKey, packTexture);
                        SaveTexture(_idKeyList, _picKeyList, _listPackTexture, id, Direction.back, packTextureKey, packTexture);
                        break;
                    }
                }
                picExtendKey++;
            }
            packTexture.Pack();
//			packTexture.Texture.Compress(true);
            _packTextureMap.Add(type, packTexture);
        }
        public void SaveTexture(List <int> idKeyList, List <int> picKeyList, List <PackTexture> packTextureList, int id, Direction direction, int picKey, PackTexture packTexture)
        {
            int idKey = GetIdKey(id, direction);

            idKeyList.Add(idKey);
            picKeyList.Add(picKey);
            packTextureList.Add(packTexture);
        }