可以通过把粒子特效作为动画事件来添加么?如果不能的话该怎么添加
可以的,这是我之前写的一个脚本,可以作为参考
public class AmtEvent : UnityObject
{
public ParticleSystem mWater;
/// <summary>
/// vect2.x表示事件类型0表示播放1表示暂停,vect2.y表示事件插入时间
/// </summary>
/// <typeparam name="Vector2"></typeparam>
/// <returns></returns>
public List<Vector2> mEventList = new List<Vector2>();
Animation mAmt;
protected override void Init()
{
base.Init();
mAmt=GetComponent<Animation>();
if (mEventList != null && mEventList.Count > 0)
{
for (int i = 0; i < mEventList.Count; i++)
{
AnimationEvent animationEvent = new AnimationEvent();
if (mEventList[i].x == 0)
{
animationEvent.functionName = "PlayParticle";
}
else
{
animationEvent.functionName = "StopParticle";
}
animationEvent.time = mEventList[i].y;
mAmt.clip.AddEvent(animationEvent);
}
}
}
void PlayParticle()
{
mWater.Play();
}
void StopParticle()
{
mWater.Stop();
}
}