C#Unity:无法更改脚本中粒子系统的颜色

时间:2016-11-19 09:20:33

标签: c# unity3d

如何在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);
    }

0 个答案:

没有答案
相关问题