I am specifically confused about the code used to toggle the emission module of the particle system on and off.
for context, the code that i initially came up with was something like this :
laser.GetComponent().emission.enabled = true;
this of course did not work as laser.GetComponent().emission is a get only property of the ParticleSystem class. which means it should be impossible to edit .enabled, as it is a property of emission, which is an instantiation of a struct called EmissionModule, which is declared within the ParticleSystem class.
so I eventually settled on this as a solution:
laser.GetComponent().enableEmission = true;
while visual studio gave me messages telling me that this was obsolete, it worked so I just went with it.
my understanding of why this works is that:
while I am not able to directly manipulate laser.GetComponent().emission as it is get only, I can however directly manipulate laser.GetComponent().enableEmission as it is get and set and i assume it does some backend joojoo that i cant see to make the particle system stop emitting.
here’s where my confusion with ricks code comes in. from my understanding of c#, what the code within the red circle would be doing is passing in the value of laser.GetComponent ().emission into the var emissionModule. so it makes sense that emissionmodule.enabled would be editable as the .enabled part is no longer a property of the get only property laser.GetComponent().emission but instead a property of var emissionModule, which would be of type EmissionModule(the struct within the ParticleSystem class). now here’s what i dont get:
why does editing emissionModule.enabled, which by my understanding should be a property of a completely separate variable(emissionModule) that only has had the value of laser.GetComponent().emission passed into it, give the same results as editing laser.GetComponent().emission.enabled directly? shouldn’t it do like, literally nothing at all?
In an attempt to find an answer on my own, I even tried replicating the situation that i am confused with in a more simplified form
and the results were demoralizingly:
proving that i was right, but also completely wrong??
sorry for the confusing clusterf*ck 500 word essay of a question but please help me lol.