At top
public Texture2D source;
public Texture2D destination;
private int sourceMipLevel = 0;
the method start
void Start()
{
Test();
}
Test method
private void Test()
{
// Get a copy of the color data from the source Texture2D, in high-precision float format.
// Each element in the array represents the color data for an individual pixel.
Color[] pixels = source.GetPixels(sourceMipLevel);
// If required, manipulate the pixels before applying them to the destination Texture2D.
// This example code reverses the array, which rotates the image 180 degrees.
System.Array.Reverse(pixels, 0, pixels.Length);
// Set the pixels of the destination Texture2D.
int destinationMipLevel = 0;
destination.SetPixels(pixels, destinationMipLevel);
// Apply changes to the destination Texture2D, which uploads its data to the GPU.
destination.Apply();
}
i tried to use image that is sprite 2d texture both source and destination same type of sprtie 2d texture but on the destination i'm getting the error in the editor :
I even tried to use the same image sprite 2d texture on both source and destination but still getting the same error.
The error is at line 68 :
destination.SetPixels(pixels, destinationMipLevel);
The error :
ArgumentException: Texture2D.SetPixels: texture uses an unsupported format. (Texture 'WithClouds') UnityEngine.Texture2D.SetPixels (System.Int32 x, System.Int32 y, System.Int32 blockWidth, System.Int32 blockHeight, UnityEngine.Color[] colors, System.Int32 miplevel
CodePudding user response:
Read up on the documentation. Most errors are explained here.
Your issue is probably with the file being crunch compressed, as explained in this forum post.