Skip to content

Instantly share code, notes, and snippets.

@michaelbartnett
Created February 5, 2016 23:40
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelbartnett/190c26b94e071a40d499 to your computer and use it in GitHub Desktop.
Save michaelbartnett/190c26b94e071a40d499 to your computer and use it in GitHub Desktop.
particle system modules are weird
ParticleSystem ps = GetComponent<ParticleSystem>();
ps.enableEmission = false;
// warning CS0618: `UnityEngine.ParticleSystem.enableEmission' is obsolete: `enableEmission property is deprecated. Use emission.enable instead.'
ps.emission.enable = false;
// error CS1061: Type `UnityEngine.ParticleSystem.EmissionModule' does not contain a definition for `enable' and no extension method `enable' of type `UnityEngine.ParticleSystem.EmissionModule' could be found (are you missing a using directive or an assembly reference?)
ps.emission.enabled = false;
// error CS1612: Cannot modify a value type return value of `UnityEngine.ParticleSystem.emission'. Consider storing the value in a temporary variable
var emission = ps.emission;
emission.enabled = false;
ps.emission = emission;
// error CS0200: Property or indexer `UnityEngine.ParticleSystem.emission' cannot be assigned to (it is read only)
var emission = ps.emission;
emission.enabled = false;
// Because we TOTALLY expect setting a property on a struct to actually
// call a function on the object you got that struct from.
@rsteckler
Copy link

Best short story of the year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment