使用精灵列表构造动画帧序列。
定义添加到纹理帧动画的精灵。
另请参阅: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.
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); } }