- Home /
Accessing Particle emitter
Hello. I am trying to do a simple shape and color change on the emitter in a particle.
I manged to do it using the UnityEditor namespace but I won't be able to use the script once it builds.
How can I change the shape and color of the emitter in code? or Is it possible to use the unityeditor namespace in a build?
Here's the code I used:
 ParticleSystem particleSystem = GetComponent<ParticleSystem>();
 particleSystem.startColor = new Color(particleSystem.startColor.r, particleSystem.startColor.g, particleSystem.startColor.b,1);
     
 SerializedObject psSerial = new SerializedObject(particleSystem);
     
 psSerial.FindProperty("ShapeModule.type").intValue = 0;
                     psSerial.FindProperty("ColorModule.gradient").FindPropertyRelative("maxGradient").FindPropertyRelative("key0").colorValue = new Color(Color.yellow.r, Color.yellow.g, Color.yellow.b, 1);
                     psSerial.FindProperty("ColorModule.gradient").FindPropertyRelative("maxGradient").FindPropertyRelative("key1").colorValue = new Color(Color.yellow.r, Color.yellow.g, Color.yellow.b, 1);
                     psSerial.FindProperty("ColorModule.gradient").FindPropertyRelative("maxGradient").FindPropertyRelative("key2").colorValue = new Color(Color.yellow.r, Color.yellow.g, Color.yellow.b, 1);
 
 
 //...
     
 psSerial.ApplyModifiedProperties();
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Shuriken mesh shape not prewarming 0 Answers
How to pause emitter in new Particle System? 2 Answers
Sub Emitter problems 2 Answers
Objects with particle emitters unexpectedly disappearing 1 Answer
A particle question 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                