ParticleSystemAnimationMode.Sprites

Unity · Версия 2020.3 LTS · Scripting · ParticleSystemAnimationMode

ParticleSystemAnimationMode.Sprites

Описание

Используйте список спрайтов для создания последовательности кадров анимации.

Определяет спрайты, добавляемые в анимацию текстурного листа.

Смотрите так же: ParticleSystemAnimationMode.Grid

using UnityEngine;

// Пример спрайта частиц.
// Игровой объект, к которому прикреплен этот скрипт, должен иметь
// ParticleSystem прилагается. Режим TextureSheetAnimation
// установлено значение Спрайты. Этот скрипт добавляет одну текстуру в
// ParticleSystem.

[RequireComponent(typeof(ParticleSystem))]
public class ExampleClass : MonoBehaviour
{
    public Texture2D tex;
    private ParticleSystem ps;
    private Sprite sprite;

    void Start()
    {
        ps = GetComponent<ParticleSystem>();
        sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), Vector2.zero);

        var textureSheetAnimation = ps.textureSheetAnimation;
        textureSheetAnimation.enabled = true;
        textureSheetAnimation.mode = ParticleSystemAnimationMode.Sprites;
        textureSheetAnimation.AddSprite(sprite);
    }
}

Обновлено 17 ноября 2026 г.