- Home /
 
               Question by 
               teopotter88 · Oct 12, 2016 at 07:10 PM · 
                audiobutton trigger events  
              
 
              Transition to new audio through a GUI Button?
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class OnCollision : MonoBehaviour { public Transform other; public GUIStyle style; public GameObject crate; public GameObject GameObject1;
 void OnGUI()
 {
     if (other)
     {
         float dist = Vector3.Distance(other.position, transform.position);
         if(dist < 20 )
         {
             if (GUI.Button (new Rect (600, 100, 100, 100), "NO")) {
                 Destroy(crate);
                 Destroy(GameObject1);
             }
             GUI.Button(new Rect(800, 100, 100, 100),"YES");
             GUI.TextArea(new Rect (600, 250, 300, 100), "Do You Want To Open This Crate?", style);
         
             }
         }
     }
}
I have this code. When the "YES" button is clicked, I want a new audio to start playing other than the main game audio. How can I implement it into this code?
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to control FMOD Studio from Unity? 3 Answers
Audio Source will not "unmute" after toggling? 2 Answers
Audio not playing... 2 Answers
Is there a way to load m4a in iOS? 0 Answers
Mac Built-In Microphone Not Working 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                