Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mesh particle emitter - access to mesh

Discussion in 'Scripting' started by Tutanhomon, Feb 4, 2011.

  1. Tutanhomon

    Tutanhomon

    Joined:
    Sep 15, 2009
    Posts:
    101
    So the problem is... I've created an empty GO, with mesh particle emitter, particle animator and particle renderer attached, and I want to gain access to the mesh property of Mesh Particle Emitter... but there's no such class, and in ParticleEmitter class this property is not presented either... I'm a lil bit confused, because I want to set the mesh for mesh emitter via code, because the mesh is created procedurally in runtime... and I still want to adjust emitter settings in editor, thats why attaching MeshParticleEmitter component in runtime doesn't work for me...
    So, any suggestions?
    Thanx a lot.
     
  2. Tutanhomon

    Tutanhomon

    Joined:
    Sep 15, 2009
    Posts:
    101
    Found a way to solve this problem (thanx to russian forum)
    I just had to create a prefab from unity cube, where I deleted collider and mesh renderer, just mesh filter left, and added particle animator, particle renderer and meshParticleEmitter. Then I just have to GetComponent<MeshFilter>() and replace it's .mesh with my own mesh. Particle Emitter will automatically use new mesh for placing particles.
    Kinda stupid way I think, still can't figure out why the heck I cannot access to Emitter's mesh...
     
  3. Antitheory

    Antitheory

    Joined:
    Nov 14, 2010
    Posts:
    549
    Thanks for posting the solution here. I also ran into trouble with this in the past.
     
  4. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    This thread, I believe. It was really a stupid problem.
     
  5. Tutanhomon

    Tutanhomon

    Joined:
    Sep 15, 2009
    Posts:
    101
    yep, it is =)