using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioController : MonoBehaviour
{
private AudioSource ads;
// Start is called before the first frame update
void Start()
{
ads=this.GetComponent<AudioSource>();
}
// Update is called once per frame
void OnGUI()
{
if (GUILayout.Button("play"))
{
if (!ads.isPlaying)
{
ads.Play();
}
}
if (GUILayout.Button("stop"))
{
if (ads.isPlaying)
{
ads.Stop();
}
}
}
}
using UnityEngine;
using System.Collections;
public class AudioController:MonoBehaviour{
private AudioSource ads;
void Start(){
ads=this.GetComponent<AudioSource>();
}
void OnGUI(){
if(GUILayout.Button("play")){
if(!ads.isPlaying)
ads.Play();
}
}
}