Changing shuriken's particle emitter sphere shape's radius through script?


I want to be able to dynamically create spheres with static particles on them. This is working nicely if I do things by hand.

How can I set the radius of the sphere used to emit the particles with shuriken through script? Is it possible?


I believe as of Unity 4 (released after this question was posted) that setting the transform scale of the gameObject auto-magically scales the Shape radius.

It’s possible when running the game in Editor; there is a workaround that gives access to several otherwise locked variables of a ParticleSystem. I only ever used it to assign different emit meshes at runtime, but I guess you could access things like radius etc. etc well. However, this will probably be useless because you can’t run the game from a Build if one of the scripts has the “using UnityEditor” line.
If you use a custom mesh as you emitting shape, the transform.scale variables of the gameobject the PS is on WILL affect the size of the emitting mesh.

//the following example assigns a mesh as a shape to the PS during runtime in Editor mode
//the following needs using UnityEditor;!
					SerializedObject so = new SerializedObject(yourGameObject.GetComponent<ParticleSystem>());
	Mesh mesh = new Mesh();				so.FindProperty("ShapeModule.m_Mesh").objectReferenceValue = mesh;