Advertisement
salahzar

U_ClickToggleSound.cs

Sep 11th, 2021
1,082
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1.  
  2. using UdonSharp;
  3. using UnityEngine;
  4. using VRC.SDKBase;
  5. using VRC.Udon;
  6. using VRC.Udon.Common.Interfaces;
  7.  
  8.  
  9. public class UdonSharp_ClickToggleSound : UdonSharpBehaviour
  10. {    
  11.     private AudioSource TheAudio;
  12.  
  13.  
  14.     public void Start() {
  15.         TheAudio = gameObject.GetComponent<AudioSource>();
  16.     }
  17.  
  18.     public override void Interact() {
  19.         SendCustomNetworkEvent(NetworkEventTarget.All,"Suona");
  20.     }
  21.  
  22.    
  23.     public void Suona() {
  24.         Debug.Log("Called Suona");
  25.         if (TheAudio.isPlaying) {                      
  26.             TheAudio.Stop();
  27.         } else {
  28.             TheAudio.Play();
  29.         }
  30.     }
  31.    
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement