如何在start方法中更改效果变量的颜色。我用effect.startColor = Color.red
尝试了它,但它根本不会改变颜色。难道它不起作用,因为我的死亡效果是这个剧本的所有实例使用的预制件吗?
using UnityEngine;
using System.Collections;
public class Obstacle : Living {
public ParticleSystem deathEffect;
public Material obstacleMaterial;
ParticleSystem effect;
public void Start(){
effect = deathEffect;
}
public override void TakeHit (float damage, Vector3 hitPoint, Vector3 bulletDirection){
AudioManager.instance.PlayFx ("Impact", transform.position);
if (health <= damage) {
AudioManager.instance.PlayFx ("EnemyDeath", transform.position);
ParticleSystem newEffect = Instantiate (effect, hitPoint, Quaternion.FromToRotation (Vector3.forward, bulletDirection)) as ParticleSystem;
Destroy (newEffect, newEffect.startLifetime);
}
base.TakeHit (damage, hitPoint, bulletDirection);
}