Legacy Documentation: Version 2017.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

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

ParticleSystem.MainModule.scalingMode

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 scalingMode: ParticleSystemScalingMode;
public ParticleSystemScalingMode scalingMode;

Description

Control how the particle system's Transform Component is applied to the particle system.

Hierarchy: Scale according to its Transform and all its parents. Local: Scale using only its own Transform, ignroing all parents. Shape: Only apply scale to the source positions of the particles, but not their size. The source positions are defined by the Shape module.

#pragma strict
// add this to a particle system which has a parent game object, to see how each scaling mode works
private var ps: ParticleSystem;
public var sliderValue: float = 1.0F;
public var parentSliderValue: float = 1.0F;
public var scaleMode: ParticleSystemScalingMode;
function Start() {
	ps = GetComponent.<ParticleSystem>();
}
function Update() {
	ps.transform.localScale = new Vector3(sliderValue, sliderValue, sliderValue);
	if (ps.transform.parent != null)
		ps.transform.parent.localScale = new Vector3(parentSliderValue, parentSliderValue, parentSliderValue);
	var main: var = ps.main;
	main.scalingMode = scaleMode;
}
function OnGUI() {
	scaleMode = ParticleSystemScalingModeGUI.SelectionGrid(new Rect(25, 25, 300, 30), intscaleMode, [new GUIContent("Hierarchy"), new GUIContent("Local"), new GUIContent("Shape")], 3);
	GUI.Label(new Rect(25, 80, 100, 30), "Scale");
	sliderValue = GUI.HorizontalSlider(new Rect(125, 85, 100, 30), sliderValue, 0.0F, 5.0F);
	GUI.Label(new Rect(25, 120, 100, 30), "Parent Scale");
	parentSliderValue = GUI.HorizontalSlider(new Rect(125, 125, 100, 30), parentSliderValue, 0.0F, 5.0F);
}
using UnityEngine;
using System.Collections;

// add this to a particle system which has a parent game object, to see how each scaling mode works public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public float sliderValue = 1.0F; public float parentSliderValue = 1.0F; public ParticleSystemScalingMode scaleMode;

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

void Update() { ps.transform.localScale = new Vector3(sliderValue, sliderValue, sliderValue); if (ps.transform.parent != null) ps.transform.parent.localScale = new Vector3(parentSliderValue, parentSliderValue, parentSliderValue);

var main = ps.main; main.scalingMode = scaleMode; }

void OnGUI() { scaleMode = (ParticleSystemScalingMode)GUI.SelectionGrid(new Rect(25, 25, 300, 30), (int)scaleMode, new GUIContent[] { new GUIContent("Hierarchy"), new GUIContent("Local"), new GUIContent("Shape") }, 3); GUI.Label(new Rect(25, 80, 100, 30), "Scale"); sliderValue = GUI.HorizontalSlider(new Rect(125, 85, 100, 30), sliderValue, 0.0F, 5.0F); GUI.Label(new Rect(25, 120, 100, 30), "Parent Scale"); parentSliderValue = GUI.HorizontalSlider(new Rect(125, 125, 100, 30), parentSliderValue, 0.0F, 5.0F); } }

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