I do get a color, but it isn’t the center sprite pixel color.
The full context is that I’m trying to change some particle colors to whatever color is at the center of a sprite that’s flipping through a strip [sprite mode = multiple, pixels per unit is 32].
print(thisEgg.GetComponent<SpriteRenderer>().sprite.name);
Texture2D myTexture = thisEgg.GetComponent<SpriteRenderer>().sprite.texture;
Color centerSpriteColor = myTexture.GetPixel(myTexture.width / 2, myTexture.height / 2);
centerSpriteColor.a = 1;
Debug.Log(centerSpriteColor);
var main = ps.main;
main.startColor = centerSpriteColor;
You’re getting the same color every time (and that color looks like a “real” value from somewhere, not a default value like pure black or pure white). That suggests to me you’re probably somehow using the same texture every time.
Are you perhaps using any sort of sprite atlas, where multiple sprites are stored in different parts of a single texture?