Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ParticleSystem.MainModule.startColor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public var startColor: ParticleSystem.MinMaxGradient;
public ParticleSystem.MinMaxGradient startColor;

Description

The initial color of particles when emitted.

See Also: MinMaxGradient.

#pragma strict
private var ps: ParticleSystem;
public var hSliderValueR: float = 0.0F;
public var hSliderValueG: float = 0.0F;
public var hSliderValueB: float = 0.0F;
public var hSliderValueA: float = 1.0F;
function Start() {
	ps = GetComponent.<ParticleSystem>();
}
function Update() {
	var main: var = ps.main;
	main.startColor = new Color(hSliderValueR, hSliderValueG, hSliderValueB, hSliderValueA);
}
function OnGUI() {
	GUI.Label(new Rect(25, 40, 100, 30), "Red");
	GUI.Label(new Rect(25, 70, 100, 30), "Green");
	GUI.Label(new Rect(25, 100, 100, 30), "Blue");
	GUI.Label(new Rect(25, 130, 100, 30), "Alpha");
	hSliderValueR = GUI.HorizontalSlider(new Rect(95, 45, 100, 30), hSliderValueR, 0.0F, 1.0F);
	hSliderValueG = GUI.HorizontalSlider(new Rect(95, 75, 100, 30), hSliderValueG, 0.0F, 1.0F);
	hSliderValueB = GUI.HorizontalSlider(new Rect(95, 105, 100, 30), hSliderValueB, 0.0F, 1.0F);
	hSliderValueA = GUI.HorizontalSlider(new Rect(95, 135, 100, 30), hSliderValueA, 0.0F, 1.0F);
}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public float hSliderValueR = 0.0F; public float hSliderValueG = 0.0F; public float hSliderValueB = 0.0F; public float hSliderValueA = 1.0F;

void Start() { ps = GetComponent<ParticleSystem>(); }

void Update() { var main = ps.main; main.startColor = new Color(hSliderValueR, hSliderValueG, hSliderValueB, hSliderValueA); }

void OnGUI() { GUI.Label(new Rect(25, 40, 100, 30), "Red"); GUI.Label(new Rect(25, 70, 100, 30), "Green"); GUI.Label(new Rect(25, 100, 100, 30), "Blue"); GUI.Label(new Rect(25, 130, 100, 30), "Alpha");

hSliderValueR = GUI.HorizontalSlider(new Rect(95, 45, 100, 30), hSliderValueR, 0.0F, 1.0F); hSliderValueG = GUI.HorizontalSlider(new Rect(95, 75, 100, 30), hSliderValueG, 0.0F, 1.0F); hSliderValueB = GUI.HorizontalSlider(new Rect(95, 105, 100, 30), hSliderValueB, 0.0F, 1.0F); hSliderValueA = GUI.HorizontalSlider(new Rect(95, 135, 100, 30), hSliderValueA, 0.0F, 1.0F); } }

Did you find this page useful? Please give it a rating: