using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class ReadPixelsFromImage : MonoBehaviour
{
public Texture2D tx2d;
// Start is called before the first frame update
void Start()
{
ReadPixelsFromT2D(tx2d);
}
// Update is called once per frame
void Update()
{
}
private void ReadPixelsFromT2D(Texture2D Texture)
{
Texture2D tex = new Texture2D(Texture.width, Texture.height, TextureFormat.RGB24, false);
// Initialize and render
RenderTexture rt = new RenderTexture(Texture.width, Texture.height, 24);
Camera.main.targetTexture = rt;
Camera.main.Render();
RenderTexture.active = rt;
// Read pixels
tex.ReadPixels(new Rect(0, 0, tx2d.width, tx2d.height), 0, 0);
Camera.main.targetTexture = null;
RenderTexture.active = null; // added to avoid errors
DestroyImmediate(rt);
}
}
i want to see all the pixels in a list but ReadPixels is a void.