Javascript 停止ParticleSystem始终运行

Javascript 停止ParticleSystem始终运行,javascript,c#,unity3d,Javascript,C#,Unity3d,如何阻止作为游戏对象插入到场景中的ParticleSystem一直运行 我只有一点想法,但还不管用 那么,假设我在我的对象层次结构中有一个名为“ParticleSystem3”的游戏对象-引用ParticleSystem3并阻止其连续发射的正确方法是什么 我不理解我发现的例子,它们似乎没有给我一个正确的分词系统的参考 我知道手册中的ParticleSystem标题下有一个播放、暂停和停止功能。如何正确使用它们?我只需要停止,所以我的问题是与分词系统相关的停止机制,正如我已经提到的 我用JS(Ja

如何阻止作为游戏对象插入到场景中的ParticleSystem一直运行

我只有一点想法,但还不管用

那么,假设我在我的对象层次结构中有一个名为“ParticleSystem3”的游戏对象-引用ParticleSystem3并阻止其连续发射的正确方法是什么

我不理解我发现的例子,它们似乎没有给我一个正确的分词系统的参考

我知道手册中的ParticleSystem标题下有一个播放、暂停和停止功能。如何正确使用它们?我只需要停止,所以我的问题是与分词系统相关的停止机制,正如我已经提到的

我用JS(JavaScript)或C#编写了这个代码

除了“谷歌it”之外,你还有什么建议吗?我似乎找不到答案,我是Unity3d 5.2的新手

您可以:

  • 使用ParcileSystem禁用游戏对象,但我怀疑这不是您想要的,因为您希望游戏对象处于活动状态

  • gameObject.GetComponent().enableEmission=false

  • gameObject.GetComponent().Stop()

  • 当需要ParticleSystem时,要再次启用它:

    gameObject.GetComponent<ParticleSystem>().enableEmission = true;
    
    gameObject.GetComponent<ParticleSystem>().Play();
    
    gameObject.GetComponent().enableEmission=true;
    gameObject.GetComponent().Play();
    
    我尝试了这个方法,但它似乎并没有停止持续发射粒子的系统。欢迎提出其他建议。如果我找到答案,我可能会把它贴在这里

    void OnCollisionEnter(Collision col)
    {
    
        if(col.gameObject.tag == "bomb")
        {
            // I got hit by a bomb! 
            Instantiate(explosion, col.gameObject.transform.position, Quaternion.identity);
    
            //ParticleSystem temp = ParticleSystem2;
            //temp.emission.enabled = false;
            ParticleSystem.EmissionModule em = ParticleSystem2.emission; 
            em.enabled = false;
            ParticleSystem2.Stop ();
    
            gameObject.GetComponent<ParticleSystem>().enableEmission = false;
            gameObject.GetComponent<ParticleSystem>().Stop();
    
    使用系统集合

    公共类NewBehaviourScript:MonoBehavior{

    // Use this for initialization
    void Start () {
        gameObject.GetComponent<ParticleSystem>().enableEmission = false;
        gameObject.GetComponent<ParticleSystem>().Stop();
    }
    
    // Update is called once per frame
    void Update () {
        //gameObject.GetComponent<ParticleSystem>().enableEmission = false;
        //gameObject.GetComponent<ParticleSystem>().Stop();
    }
    
    //将其用于初始化
    无效开始(){
    gameObject.GetComponent().enableEmission=false;
    gameObject.GetComponent().Stop();
    }
    //每帧调用一次更新
    无效更新(){
    //gameObject.GetComponent().enableEmission=false;
    //gameObject.GetComponent().Stop();
    }
    
    }


    现在它成功了。

    我尝试了以下方法:(数字澄清了顺序,整个试用期为1-4)1。公共参与制度;2.var exp=gameObject.GetComponent();3.var temp=经验排放量;4.temp.enabled=false;对我来说,这些没有做任何明显的检查答案,应该有帮助。谢谢你的回复。我很快就会看这个。我不知道这个板的功能与答案有关,但正如我上面所说的,是的,我仍在尝试将ParticleSystem设置为停止或其他。这里的线索对我不起作用。
    // Use this for initialization
    void Start () {
        gameObject.GetComponent<ParticleSystem>().enableEmission = false;
        gameObject.GetComponent<ParticleSystem>().Stop();
    }
    
    // Update is called once per frame
    void Update () {
        //gameObject.GetComponent<ParticleSystem>().enableEmission = false;
        //gameObject.GetComponent<ParticleSystem>().Stop();
    }