Code (CSharp): public List<SpriteRenderer> spritebox = new List<SpriteRenderer>(); public List<Color> colorbox = new List<Color>(); void Start() { Color color = colorbox[0]; spritebox.[0].color = color; }
As per the error message, you're trying to assign single values to a List. Use the List's Add method instead; Code (CSharp): var renderer = GetComponent<SpriteRenderer>(); spritebox.Add(renderer); colorbox.Add(renderer.color);
did not work very well because I'm trying to set the color for the sprite. and not from the sprite to the list I did this in a different way, but this error appears.
Well, it's the solution to your original question but you've since edited your post and replaced it with a whole different problem. The error you're now seeing is due to empty Lists. If your intention is to assign values in the inspector then remove the initialisers to prevent your fields being overwritten when you enter playmode; Code (CSharp): public List<SpriteRenderer> spritebox; public List<Color> colorbox; void Start() { Color color = colorbox[0]; spritebox.[0].color = color; }