0
Follow
0
View

How does unity make particle effects last

crazyfanrui 注册会员
2023-02-27 21:25

In Unity particle effects, if you do not want to set loops and do not change the starting life, you can make particles persist in one of two ways:

1. Use the Duration property of the Particle System. This property specifies the duration of the particle system. Once the duration of the particle system is over, the particles will stop firing. Setting the Duration property to a high value allows the particles to persist for a long time.

2. By controlling the emitter of the particle system in the script, it is possible to make the particle persist without changing the initial lifetime of the particle system. For example, you can use the emit parameter to emit a single particle and then emit the next one after the particle is gone to maintain the continuity of particle existence.

If you want to change the initial lifetime without changing the particle size, you can do this by adjusting the scale of the particle. In the Renderer property of the Particle System component, you can find the Material property, in the Material property you can find the Texture Sheet Animation module, in this module you can find the Tiles property, Set it to 1x1(using only one texture) and then set the Frames Per Second property to 0 so that the texture of each particle can be fixed and the Size and Lifetime of the particle can be controlled by adjusting the Start Size and Start Lifetime properties. By adjusting the Start Lifetime attribute, the particle lifetime can be controlled, and by adjusting the Start Size attribute, the particle size can be controlled. The scaling will not affect the size of the particles because they are already fixed.

koxingchen 注册会员
2023-02-27 21:25

This answer quotes ChatGPT

In Unity particle effects, if you don't want the particle to loop and don't change the particle's lifetime(i.e., start lifetime), you can make the particle persist in one of two ways:

Set particle duration
In the particle effects component's Inspector, there is a Duration property that sets the duration of the particle effects. Setting this property to a long time allows the particle to exist until the end of time.

Control particle life cycle by scripting
You can control particle life cycle by writing C# scripts. By getting the particle effects component in the script and setting Stop Action to Stop action.None, you can keep particles around until you manually stop them.

For example, here is an example of a simple script to keep particles present throughout a scene:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ParticleController : MonoBehaviour
{
    ParticleSystem particles;

    void Start()
    {
        particles = GetComponent();
        particles.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
    }

    void Update()
    {
        if (!particles.isPlaying)
        {
            particles.Play();
        }
    }
}

If you want to change the particle's lifetime(i.e. start lifetime) without changing the particle's Size, you can set the Size over Lifetime module's size attribute to a constant value in the particle Effects Inspector. And set its Multiplier property to 0. This allows the particles to remain the same size, but their lifetimes will vary.

About the Author

Question Info

Publish Time
2023-02-27 21:25
Update Time
2023-02-27 21:25

Related Question

UNITY新建脚本一直提示连接服务器是怎么回事?

vs 的spectral.imshow闪退

How can I populate the "code" column for a VS Code problem created by my extension?

电脑死机unity场景内的物体丢失

Unity广告。广告加载,但当观看时,只有介绍显示,广告不会进一步显示

How to add default implementation using generic protocol extension?

不能在Unity中导入包

unity导出后UI位置变了该怎么办

ubuntu18.04.安装gmp6.2.1时make报错

关于#unity#shader editor的问题,如何解决?