Version: 2021.3

描述

使用精灵列表构造动画帧序列。

定义添加到纹理帧动画的精灵。

另请参阅:ParticleSystemAnimationMode.Grid

using UnityEngine;

// A particle sprite example. // The gameobject this script is attached to must have the // ParticleSystem attached. The TextureSheetAnimation mode // is set to Sprites. This script adds a single texture to // the 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); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961