- Home /
Cant Change Color of the Particle System
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JumpParticleColor : MonoBehaviour {
private ParticleSystem theParticleSystem;
// Use this for initialization
void Start () {
theParticleSystem = GetComponent<ParticleSystem>();
PlayerPrefs.SetFloat("JumpParticleColor", 0);
}
// Update is called once per frame
void Update () {
if (PlayerPrefs.GetFloat("JumpParticleColor")==0)
{
theParticleSystem.main.startColor = Color.red;
}
}
}
CANT MODIFY PARTICLE SISTEM. MAIN BECAUSE IS NOT A VARIABLE
Comment
Answer by ifurkend · Mar 13, 2017 at 08:13 AM
Refer this official blog: https://blogs.unity3d.com/en/2016/04/20/particle-system-modules-faq/
You need to have a var to define the particle module first then access its functions. For example:
ParticleSystem ps;
ParticleSystem.MainModule main;
void Start(){
ps = GetComponent<ParticleSystem>();
main = ps.main;
main.startColor = new Color(1,0,0,1);
}
Your answer
Follow this Question
Related Questions
How to get a list of particles 1 Answer
How to Activate Particle System? 0 Answers
Particle system won't stick to player after shoot 0 Answers
Accessing local system ( File Browser ) 2 Answers
Custom Particle System 1 Answer