RaycastHit

http://docs.unity3d.com/ScriptReference/ParticleSystem-duration.html


ParticleSystem



Variables


duration

类型:float

粒子系统持续的时间,以秒为单位(只读)。


emissionRate

类型:float

发射速率。


enableEmission

类型:bool

设为false时,粒子系统不再发射粒子。


gravityModifier

类型:float

缩放由Physics.gravity定义的重力大小。(粒子受到缩放后重力的影响)


isPaused

类型:bool

此刻粒子系统处于暂停状态?


isPlaying

类型:bool

此刻粒子系统正在运行?


isStopped

此刻粒子系统已经停止?


loop

类型:bool

粒子系统循环播放?

如果你关闭一个正在播放的粒子系统的循环模式,他会在本次播放结束后停止。


maxParticles

类型:int

发射的最大粒子数。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public float hSliderValue = 0.0F;
    public ParticleSystem part;

    void Start() {
        part = GetComponent<ParticleSystem>();
    }
    
    void Update() {
        part.maxParticles = Mathf.RoundToInt(hSliderValue);
    }
    
    void OnGUI() {
        hSliderValue = GUI.HorizontalSlider(new Rect(25, 25, 100, 30), hSliderValue, 0.0F, 100.0F);
    }
}
particleCount

类型:int

当前粒子的数量。(只读)


playbackSpeed

类型:float

粒子系统的播放速度。1表示正常速度。不支持负数。


playOnAwake

类型:bool

设为true时,粒子系统在游戏启动时自动开始播放。


randomSeed

类型:unit

随机种子是给粒子系统的发射使用的。如果设为0,他会被指定为一个随机值。


simulationSpace

类型:ParticleSystemSimulationSpace

这里可以选择在哪个空间模拟粒子。它可以使世界坐标系或自身坐标系。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public ParticleSystem part;
    public bool useLocal = true;
    void Start() {
        part = GetComponent<ParticleSystem>();
        useLocal = part.simulationSpace == ParticleSystemSimulationSpace.Local;
    }
    void Update() {
        part.simulationSpace = ((useLocal) ? ParticleSystemSimulationSpace.Local : ParticleSystemSimulationSpace.World);
    }
    void OnGUI() {
        useLocal = GUI.Toggle(new Rect(10, 60, 200, 30), useLocal, " Use Local Simulation Space");
    }
}
startColor

类型:Color

当粒子被发射时的初始化颜色


startDelay

类型:float

延迟开始,秒为单位。

用这个来延迟系统开始播放。


startLifetime

类型:float

发射后,粒子能生存的时间,秒为单位。如果使用弯曲,这个值也会随弯曲而缩放。这个值用来设置粒子,当粒子被系统创建后。


startRotation

类型:float

粒子发射时的初始化旋转。如果使用弯曲,这个值也会随弯曲而缩放。注意这个值应该是个弧度。


startSize

类型:float

粒子发射时的初始化尺寸。如果使用弯曲,这个值也会随弯曲而缩放。


time

类型:float

播放的时间。通过这个值可以读取当前播放的时间。




Public Functions


Clear

类型:void Clear(bool withChildren = true);


参数:

withChildren  也清理所有子粒子系统


移除粒子系统中的所有的粒子。



Emit

类型1: void Emit(int count)

立即发射count个数的粒子。


类型2: void Emit(Vector3 position, Vector3 velocity, float size, float lifetime, Color32 color)

参数:

position 粒子的位置

velocity 粒子的速度

size  粒子的尺寸

lifetime  粒子持续的时间

color   粒子的颜色


参照给出的参数立即发射一个粒子


类型3:void Emit(Particle particle)

发射一个粒子。


GetParticles

类型:int GetParticles(Particle[] particles)

参数:

particles  用来存储粒子状态的粒子缓存。返回值是写入这个数组的粒子数量。


返回:

当前还有生命的粒子的数量。


获得这个粒子系统的粒子。

This method is allocation free as long the input "particles" array is preallocated once (see example below). Note that only a small part of the particles array might be used as this depends on how many particles are currently alive in the particle system when calling GetParticles().

using UnityEngine;

[RequireComponent(typeof(ParticleSystem))]
public class ParticleFlow : MonoBehaviour
{
	ParticleSystem m_System;
	ParticleSystem.Particle[] m_Particles;
	public float m_Drift = 0.01f;

	private void LateUpdate()
	{
		InitializeIfNeeded();

		// GetParticles is allocation free because we reuse the m_Particles buffer between updates
		int numParticlesAlive = m_System.GetParticles(m_Particles);

		// Change only the particles that are alive
		for (int i = 0; i < numParticlesAlive; i++)
		{
			m_Particles[i].velocity += Vector3.up * m_Drift;
		}

		// Apply the particle changes to the particle system
		m_System.SetParticles(m_Particles, numParticlesAlive);
	}

	void InitializeIfNeeded()
	{
		if (m_System == null)
			m_System = GetComponent<ParticleSystem>();

		if (m_Particles == null || m_Particles.Length < m_System.maxParticles)
			m_Particles = new ParticleSystem.Particle[m_System.maxParticles]; 
	}
}

IsAlive

类型: bool IsAlive(bool withChildren=true)

参数:

withChildren  也检查所有子系统


返回:

如果粒子系统还"活着"返回true,如果粒子系统已经发射完毕并且全部粒子已经消亡返回false



Pause

类型:void Pause(bool withChildren=true);

参数:

withChildren  也暂停子系统


暂停播放粒子系统


Play

类型: void Play(bool withChildren=true)

参数:

withChildren 也播放所有的子系统


播放粒子系统


SetParticle

类型:void SetParticle(Particle[] particles, int size)


设置粒子系统的粒子。size是设置的粒子个数。



Simulate

类型:void Simulate(float t, bool withChildren=true, bool restart=true)

参数:

t:    快进的时间

withChildren 也快进所有子系统

restart   重新开始


快进time时间,然后暂停


Stop

类型:void Stop(bool withChildren=true)

参数:

withChildren 也停止子系统


停止运行粒子系统.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值