Code to Colors of Sprites

Hello,

I am spanish and my english is not very good, I hope you understand me.

I am new to Unity.

I have been looking for how to put a code that does:

I want to see all the colors of my Sprite and be able to modify them.

Ex: The Sprite of a car is white, blue and black.
Make these colors appear in a list and be able to modify them.

I have found the following code but it doesn’t work:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
public class ChangeColor : MonoBehaviour
{
public Color[ ] colores;
public Queue QueueColor = new Queue ();
public SpriteRenderer spriteRenderer;

// Use this for initialization
void Start()
{
spriteRenderer = GetComponent ();

foreach (Color c in colores)
{
QueueColor.Enqueue (c);
}
}

// Update is called once per frame
void Update()
{
if (Input.GetKeyDown (KeyCode.Space))
{
Invoke (“NextColor”,0);
}

public void NextColor()
{
Color c = QueueColor.Dequeue ();
spriteRenderer.color = c;
QueueColor.Enqueue (c);
}
}

Is it possible to do what I want? What would the code be?

You can use sprite.texture.GetPixels(); You should also set your sprites to read/write enabled. This can be done by selecting the sprite and in the inspector under advanced → Read/Write