using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class ReadPixelsFromImage : MonoBehaviour
{
public Texture2D tx2d;
public RawImage ri;
// Start is called before the first frame update
void Start()
{
ReadPixelsFromT2D(tx2d);
ri.texture = tx2d;
}
// Update is called once per frame
void Update()
{
}
private void ReadPixelsFromT2D(Texture2D Texture)
{
Color[] colors = Texture.GetPixels();
for (int i = 0; i < colors.Length; i++)
{
if (colors[i] == Color.blue)
{
colors[i] = Color.yellow;
}
}
Texture.SetPixels(colors);
Texture.Apply();
}
}
if i’m not check for the blue color in the line :
if (colors[i] == Color.blue)
then it will color all the pixels in yellow but i want to color in yellow now only some of the pixels.
but checking against blue color find nothing like there are no clue pixels but in the image there is a lot of blue :