What does it mean that the particle system's properties are interfaces into the native code

Hi, I’m trying to understand the Particle System section of the Unity documentation. I’m confused about the following part that says:
“Particle System properties are grouped by the module they belong to, such as ParticleSystem.noise and ParticleSystem.emission. These properties are structs, but do not behave like normal C# structs. They are simply interfaces directly into the native code, so it is important to know how to use them, compared to a normal C# struct.
The key difference is that it is not necessary to assign the struct back to the Particle System component. When you set any property on a module struct, Unity immediately assigns that value to the Particle System.”
Specifically, I don’t understand what it means for the particle system’s properties to be interfaces into the native code, and I don’t understand why this means it is not necessary to assign the struct back to the particle system component.
Honestly, it is possible for me to do what I want without knowing this, but I am curious.

Unity is a C++ game engine with the C# interface on top that we use. The vast majority of the C# code you’re working with is actually smoke and mirrors calling back to the native C++ code, even innocent looking things like gameObject.tag. You don’t need to worry about it too much, just code away and Unity will handle the rest.

1 Like

Unity’s C# managed part of the engine is actually up on their github repository. The code is organised a bit confusing for some things, however here’s the source code for the MainModule struct. Note that all those fields are not fields of the struct but actually properties. As you may know, C# properties are actually just fancy syntax for a pair of methods, one get method and one set method (though it’s possible to have properties with just a get or just a set method). Also as you can see those properties do not contains any code as they are declared as “extern”. That means they are linked to native code. So calling those methods actually calls a method in the native C++ part of the engine.