So I am trying to change my color of my sprite to a rgb color. Now I can just change it to a color like red, black or blue...
m_spriteRenderer.color = Color.blue;
Thanks,
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityYou can pass the color you want to the constructor of the Color object.
Here is a copy of the documentation's example:
using UnityEngine;
public class Example : MonoBehaviour
{
void Start()
{
Color newColor = new Color(0.3f, 0.4f, 0.6f);
}
}
You can also use it like that:
Color newColor = new Color(0.3f, 0.4f, 0.6f);
m_spriteRenderer.color = newColor;
You can see an example of how it can be used in the documentation of the SpriteRenderer.color function.
new Color32(127, 63, 0xFF)
. These 32-bit colours will implicitly convert to and from the floating point color type, so you can use whichever is clearest for your needs.
\$\endgroup\$