public static Texture2D TextureCut(Texture2D tex,float ratio = 0.8f)
    {
        if (tex == null)
            return null;
        if (ratio <= 0)
            return tex;
        Color color;
        int width = (int)(tex.width * ratio);
        int height = (int)(tex.height * ratio);
        Texture2D newTexture = new Texture2D(width,height, TextureFormat.RGB24, false);
        float newWidthGap = width * ratio;
        float newHieghtGap = height * ratio;
        for (int i = 0; i < newTexture.height; i++)
        {
            for (int j = 0; j < newTexture.width; j++)
            {
                color = tex.GetPixel((int)(j * (1 / ratio)), (int)(i * (1 / ratio)));
                newTexture.SetPixel(j, i, color);
            }
        }
        return newTexture;
    }

  

相关文章:

  • 2021-05-17
  • 2021-04-12
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
猜你喜欢
  • 2021-10-12
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
相关资源
相似解决方案