Changing values of component directly not OK? (particleEmitter.particles[...].color)

Hi,

I am slightly confused with local copies and copying by reference. Here is my setup:

public class minimal : MonoBehaviour
{
    private Particle[] particles;

    void Start()
    {
        particleEmitter.Emit(iterations);
        particles = particleEmitter.particles; // (*1*)

        particleEmitter.particles[i].color = Color.red; // (*2*)
        // does not have an effect (for some i). Instead, however,

        particles[i].color = Color.red; // (*3*)
        // does draw the particle as red. 
    }
}

I would expect that (1) is a local copy. But judging by the result of (3), it looks like it is actually a copy of the reference addresses in the memory. I am also surprised why you cannot access the component directly, as in (2). Could someone explain this?

You should have gotten a runtime error about not changing it directly. Who knows why? When I get that error, I use a variable.

Ok but can anyone explain why (1) is a copy by reference rather than by value?

Thats just the way it is.
imagine if you had an array of gameObjects
GameObject[ ] myGOs
if you then went
GameObject[ ] sortedGOS = myGOs
sortedGOs.sort()
you wouldnt want it to make a clone of every object in the array, would wreak havoc on your game, suddenly 2 of everything, just to get a sorted list of them.
It’s the way its always been.

Even without lists:
GameObject A;
GameObject B = A;
They are the same GO, not copies.