每天进步一点点:OnMouseDown() or input.GetMouseButtonUp(0)

来源:互联网 发布:市场数据分析方法 编辑:程序博客网 时间:2024/06/03 18:47
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class music : MonoBehaviour
{
    AudioSource myaudio;
    bool flag = true;
    // Use this for initialization
    void Start()
    {
        myaudio = GetComponent<AudioSource>();
    }
  void OnMouseDown() {
        if (flag)
        {
            myaudio.Play();
            flag = false;
        }
        else
        {
            myaudio.Pause();
            flag = true;
        }
    }
    // Update is called once per frame
    void Update()
    {
        //if (Input.GetMouseButtonUp(0))
        //    if (flag)
        //    {
        //        myaudio.Play();
        //        flag = false;
        //    }


        //    else
        //    {
        //        myaudio.Pause();
        //        flag = true;
        //    }


        //if (Input.GetMouseButtonUp(1))
        //{
        //    myaudio.Stop();
        //    flag = true;
        //}
    }
}
0 0
原创粉丝点击