Get sprite color r,g,b,a, values c#

How do I access sprite’s color values? (line 16)

using UnityEngine;
using System.Collections;
 
public class scr_spriteFade : MonoBehaviour {
 
        private float orgR;
        private float orgG;
        private float orgB;
        private float orgA;
 
        public float alphaAmount = 63.75f;
        public float fadeTime = 1.0f;
 
        // Use this for initialization
        void Start () {
                Color32 orgColor = /*somehow get the original r,g,b,a channel values and store them in "orgColor" */ ;
 
                orgR = orgColor.r;
                orgG = orgColor.g;
                orgB = orgColor.b;
                orgA = orgColor.a;
        }
}

Like when you want transform’s values, you’d use something like:

Vector3 orgPos = transform.localPosition;

Is there a similar way to access the color values?

If you take a look at the Sprite documentation you’ll see that it refers to the SpriteRenderer as the component that is responsible for displaying the sprite graphic. Looking at that component you’ll see that it has a 3 property.

So given your sprite game object you need to use GetComponent to get a reference to the SpriteRenderer, and that will give you access to the color property.

Try this:
using UnityEngine;
using System.Collections;

 public class scr_spriteFade : MonoBehaviour {
  
         private Color original_color;
  
         public float alphaAmount = 63.75f;
         public float fadeTime = 1.0f;
  
         // Use this for initialization
         void Start () {
                 original_color = GetComponent<SpriteRenderer>().color;
         }
 }

So I’m getting the sprite renderer component in ‘start’, and storing the color. Note that I’m not storing the initial value as separate floats - its a color, so I’m storing it as a color!

-Chris