• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Kleptomaniac · Feb 25, 2012 at 03:13 AM · meshparticleshurikenshapemesh particle emitter

Shuriken Particle System - Accessing the emitter mesh through script

Hi there,

I have been looking everywhere for this, but to no avail. Basically, how do you access the mesh variable within the shape module on the new Shuriken particle emitters? The current documentation on Shuriken in the script reference (here: http://unity3d.com/support/documentation/ScriptReference/ParticleSystem.html) has no reference to variables in other modules other than the Initial Module.

The reason I'd like to access it through script is because I am wanting to procedurally generate meshes for volumetric cloud systems. If there is actually no way to access it, well I suppose I'd need to go back to the drawing board ...

Sorry for the long post size ... I'm not great at being succinct! :D

Thanks very much, Klep

Comment
Nonakesh
Berenger
nschrag
Datael
ThibaultD
lancerfour
BlueRaja_2014
Menion-Leah

People who like this

8 Show 9
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kleptomaniac · Mar 01, 2012 at 08:21 AM 0
Share

So is there absolutely no way to access this variable?

avatar image Kleptomaniac · Apr 08, 2012 at 03:53 PM 0
Share

I know that this will be a shameless BUMP, but this still affects me. Maybe it has some relevance now that 3.5 has been out for quite some time?

avatar image Graphicated · Apr 09, 2012 at 01:33 AM 1
Share

well, I dont want to dissapoint you, but, you cant, i had the same problem, BUT , it will be added soon as I read in unity forums from the Unity HQ Coppenhagen : "In the next release of Shuriken this will be possible. Shuriken will use the transform.scale for emitter size."

avatar image yoyo · Apr 22, 2012 at 04:33 AM 1
Share

If you're just trying to dynamically change the scale of the effect you can do this with an animation curve that modifies the scale properties of the emitter. You can create an animation that blends between your minimum and maximum size, and then procedurally set the current time of the animation (AnimationState.normalizedTime) to select the desired scale. A little indirect, but it works for the particular use case of resizing the effect.

avatar image Jerware · Oct 25, 2012 at 07:06 PM 1
Share

So is this "fixed" in Unity 4?

Show more comments

4 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Benoit Dufresne · Mar 07, 2013 at 07:01 PM

I'm using Unity 4, and this doesn't seem to be in yet. I can't find documentation for it either.

I'm fairly annoyed that "legacy" is used to describe the only fully-functional particle system. I would have gone with the old system from the get-go with if wasn't called "Legacy" and Shuriken was called "Beta" instead.

Comment
DaveA
BlueRaja_2014

People who like this

2 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by kat0r · Feb 21, 2014 at 07:29 PM

If you still want it, and because there was a reply 10days ago:

  SerializedObject so = new SerializedObject(GetComponent<ParticleSystem>());
  so.FindProperty("ShapeModule.m_Mesh").objectReferenceValue = myMesh;
  so.ApplyModifiedProperties();

May require "using UnityEditor;"

You can basically access everything in the ShurikenSystem with that, see: http://answers.unity3d.com/questions/483831/how-to-modify-particlesystem-from-editor-script.html

Comment
Tetrad
Polak149

People who like this

2 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Idioismist · Jun 20, 2014 at 05:08 PM 0
Share

Not "may require 'using UnityEdtior'"

As of Unity4.5, SerializedObject absolutely will require the UnityEdtior namespace and therefore will not compile.

avatar image WILEz1975 · Sep 05, 2014 at 02:05 PM 0
Share

Tnx kat0r! Fantastic solution!

avatar image

Answer by Corngood · Oct 10, 2013 at 12:37 AM

Shuriken seems to deal with the mesh being modified at runtime, so I've just created an empty mesh asset, hooked it to both the emitter and the script component which creates the vertices. It's a silly hack for something that should have been exposed, and I haven't found a way to get multiple instances of a emitter prefab with unique mesh data.

Something I noticed was that it will only emit for vertices on triangles, so I've had to create fake triangles for my point cloud. Setting indices with 'point' topology caused Unity to crash (4.2.1).

Comment
BlueRaja_2014

People who like this

1 Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image danielnjackson · Mar 24, 2015 at 07:04 PM 0
Share

Hey,

I've been trying to get a particle emitter to emit from a procedurally generated mesh (a point cloud that I'm reading into unity from a text file), and it sounds like you found a way to do that but I'm confused about the fake triangles. Are you setting them manually or doing it in scripting? I really appreciate any help you can give me. Do you have any code I could look at?

Thanks!

avatar image Corngood · Mar 25, 2015 at 11:51 AM 1
Share

We just add points and triangles to the mesh like this:

 mesh.vertices = points;
 var triangles = new int [(points.Length + 2) / 3 * 3];
 var j = 0;
 for (; j < points.Length / 3 * 3; ++j)
     triangles[j] = j;
 for (; j < triangles.Length; ++j)
     triangles[j] = points.Length - 1;
 mesh.triangles = triangles;
 

I haven't looked at this since Unity 4.3, so it's possible that things have been fixed/improved.

avatar image danielnjackson · Mar 28, 2015 at 05:30 PM 0
Share

Hey,

Thanks so much! I'm checking to see if anything has improved, but that got me up and running for now.

avatar image

Answer by syslord2k2 · Nov 25, 2013 at 04:04 PM

You can access the mesh component of the Shuriken Renderer section by accessing the ParticleSystemRenderer component like this (c#)

 gameObject.GetComponent<ParticleSystemRenderer>().mesh
Comment
drenzior

People who like this

1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Alf203 · Feb 10, 2014 at 08:13 PM 1
Share

@ syslord2k2

That is to access the mesh that is being rendered, not the one being used as an emitter in the shape module. So that doesn't work.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to import particle emitter mesh without inner edges? 0 Answers

Particle System (shuriken) with mesh particles, change color? 0 Answers

Change new Shuriken Particle System mesh/texture in script? 0 Answers

Shuriken mesh size over lifetime question 0 Answers

Particle Effect (Shuriken) mesh emitter how to? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges