Unity中实现鼠标点击一下粒子系统播放一下

2021/9/16 23:08:30

本文主要是介绍Unity中实现鼠标点击一下粒子系统播放一下,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

第一步 取消勾选lopping

 第二步  取消勾选Play on Awake

 第三步 编写代码 (注意:类的名字要跟代码文件命名一致)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Particle : MonoBehaviour
{
    public ParticleSystem p;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            p.Play();
        }
    }
}

最后 ctrl + s 保存   就可以



这篇关于Unity中实现鼠标点击一下粒子系统播放一下的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程