//public bool CheckImageDirectory()
    //{

    //    if (Directory.Exists(t_path) && Directory.Exists(s_path) && File.Exists(PostsPath))
    //    {
    //        if(Directory.GetFiles(t_path).Length != 0 && Directory.GetFiles(s_path).Length != 0)
    //        {
    //            return true;
    //        }
    //        return true;
    //    }
    //    else
    //    {
    //        Directory.CreateDirectory(t_path);
    //        Directory.CreateDirectory(s_path);
    //        return false;
    //    }
    //}

    public IEnumerator CreateMaterials(_atlas a)
    {
        a._CreatedMaterials.Clear();

        foreach (Rect _rect in a.rect)
        {
            Material _mat = new Material(a.atlas);

            _mat.SetTextureScale("_MainTex", new Vector2(_rect.width, _rect.height));
            _mat.SetTextureOffset("_MainTex", new Vector2(_rect.x, _rect.y));

            a._CreatedMaterials.Add(_mat);
            yield return(null);
        }
    }
    public IEnumerator Pack(_atlas a, int size, Texture2D[] _textures)
    {
        //packing textures from download


        //Texture2D[] Sprites = new Texture2D[_textures.Length];
        //for (int i = 0; i < _textures.Length; i++)
        //{
        //    Sprites[i] = posts[i].StandartTexture;
        //}

        Texture2D texture = new Texture2D(2, 2);

        a.rect = texture.PackTextures(_textures, 5, size);
        a.atlas.SetTexture("_MainTex", texture);
        Debug.Log("Atlas width: " + a.atlas.mainTexture.width + "Atlas height: " + a.atlas.mainTexture.height);
        yield return(null);
    }
 //returning offset by image id
 public Material GetMaterialById(_atlas a, int id)
 {
     return(a._CreatedMaterials[id - 1]);
 }