Created
August 23, 2020 11:59
-
-
Save aiya000/b77668748e319b375d18bb30f63a4c7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UdonSharp; | |
using UnityEngine; | |
using VRC.SDKBase; | |
using VRC.Udon; | |
public class PlayPauseAudioSource : UdonSharpBehaviour { | |
public AudioSource audio; | |
private bool hasPlayed = false; | |
public override void Interact() { | |
if (this.audio == null) { | |
Debug.Log("The audio has not set."); | |
return; | |
} | |
if (!this.hasPlayed) { | |
this.audio.Play(); | |
this.hasPlayed = true; | |
return; | |
} | |
if (this.audio.isPlaying) { | |
this.audio.Pause(); | |
return; | |
} | |
this.audio.UnPause(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment