public static void SetAnimations(Texture2D givenTexture)
    {
        Color     animationColour        = transparent;
        Rect      currentAnimationBorder = new Rect(new Vector2(0, 0), new Vector2(givenTexture.width, 0));
        SpriteMap currentSpriteMap       = new SpriteMap();

        for (int i = 0; i <= givenTexture.height; i++)
        {
            Color pixelColour = givenTexture.GetPixel(0, i);
            if (pixelColour.a == 0)
            {
                if (i - currentAnimationBorder.y > 0)
                {
                    if (animationColour.a != 0)
                    {
                        if (animationColour != currentSpriteMap.GetColour())
                        {
                            currentSpriteMap = new SpriteMap();
                            currentSpriteMap.Initialise(givenTexture.name, animationColour);
                            layerList.Add(currentSpriteMap.m_index, currentSpriteMap);
                        }
                        currentAnimationBorder.size = new Vector2(currentAnimationBorder.size.x, i - currentAnimationBorder.y - 1);
                        PlayAnimation currentAnimation = SetAnimation(currentAnimationBorder, animationColour, givenTexture);
                        currentSpriteMap.AddAnimation(currentAnimation);
                    }
                }
                while (givenTexture.GetPixel(0, i).a == 0)
                {
                    i++;
                    if (i == givenTexture.height)
                    {
                        break;
                    }
                }
                currentAnimationBorder.y = i;
                animationColour          = pixelColour;
            }
            else if (i == givenTexture.height)
            {
                if (pixelColour.a == 0)
                {
                    throw new TextureNotfoundException(givenTexture.name + " didn't find any textures to make an animation from");
                }
                if (animationColour != currentSpriteMap.GetColour())
                {
                    currentSpriteMap = new SpriteMap();
                    currentSpriteMap.Initialise(givenTexture.name, animationColour);
                    layerList.Add(currentSpriteMap.m_index, currentSpriteMap);
                }
                currentAnimationBorder.size = new Vector2(currentAnimationBorder.size.x, i - currentAnimationBorder.y - 1);
                Rect          currentFrameBorder = new Rect(currentAnimationBorder.position, new Vector2(0, currentAnimationBorder.size.y));
                PlayAnimation currentAnimation   = SetAnimation(currentAnimationBorder, animationColour, givenTexture);
                currentSpriteMap.AddAnimation(currentAnimation);
            }
            else
            {
                animationColour = pixelColour;
            }
        }
    }
    public static void SetAnimations(Sprite givenSprite, ref Dictionary <string, SpriteMap> givenDictionary)
    {
        Color     animationColour        = transparent;
        Rect      currentAnimationBorder = new Rect(new Vector2(0, 0), new Vector2(givenSprite.rect.size.x, 0));
        SpriteMap currentSpriteMap       = new SpriteMap();
        string    currentSpriteMapId;

        for (int i = 0; i < givenSprite.rect.size.y; i++)
        {
            Color pixelColour = givenSprite.texture.GetPixel(0, i);
            if (animationColour != pixelColour)
            {
                if (pixelColour != transparent)
                {
                    if (animationColour != transparent)
                    {
                        currentSpriteMapId = currentSpriteMap.GetName() + ColourToString(currentSpriteMap.GetColour());
                        givenDictionary.Add(currentSpriteMapId, currentSpriteMap);
                    }
                    animationColour          = pixelColour;
                    currentAnimationBorder.y = i;
                    currentSpriteMap.Initialise(givenSprite.name, animationColour);
                }
                else
                {
                    currentAnimationBorder.size = new Vector2(currentAnimationBorder.size.x, i - currentAnimationBorder.y);
                    PlayAnimation currentAnimation = SetAnimation(currentAnimationBorder, animationColour, givenSprite.texture);
                    currentSpriteMap.AddAnimation(currentAnimation);
                    i += YGAP - 1;
                    currentAnimationBorder.y = i + 1;
                }
            }
            else if (i == givenSprite.rect.size.y - 1)
            {
                if (pixelColour == transparent)
                {
                    throw new TextureNotfoundException(givenSprite.name + " didn't find any textures to make an animation from");
                }
                currentAnimationBorder.size = new Vector2(currentAnimationBorder.size.x, i - currentAnimationBorder.y);
                Rect          currentFrameBorder = new Rect(currentAnimationBorder.position, new Vector2(0, currentAnimationBorder.size.y));
                PlayAnimation currentAnimation   = SetAnimation(currentAnimationBorder, animationColour, givenSprite.texture);
                currentSpriteMap.AddAnimation(currentAnimation);
                i += YGAP - 1;
            }
        }
        currentSpriteMapId = currentSpriteMap.GetName() + ColourToString(currentSpriteMap.GetColour());
        givenDictionary.Add(currentSpriteMapId, currentSpriteMap);
    }