c# - Play and Stop Audio with 2 seprate button Unity -
I am new to unity and am trying to use as two quads buttons and am using a script to prevent an audio file. I have searched the Internet and I have not found any solution to my problem.
This is my code
using UnityGen; Using System.Collections; Public Square Playstop: Monobehavik {Public Game Object Button 1; Public Game Object Button 2; Public audio clips clip; Zero Start () {Button 1 = Game Object.Find ("F1 Play"); Button 2 = Game Object.Find ("Fa1Stop"); } Zero OnMouseDown (if (Button 1. GETComponent ("Fa1Play") {if (audio! Appearing} {audio.clip = clip; audio.Play ();}} If (Button 2. GateConnector ("Fa1Stop ")} {Audio.Stop ();}}}}
No need to just give your button collider and tag, pause your pause tag and play a play tag
public class playstop: monobahavier {public audio clip a clip; private bull stop; zero start () {Audio.clip = aclip; stop = true} Zero update ( ) {If (Input.touches.Length == 1) {Touch touched finger = input. Touches [0]; if (touchedfuser.face == touchphase.organization) {Ray hey = camera.ManCamera. ScreenpointTorai (touched finger.) ; Recycle Hit Hit; if (Physics. Recast (ARA Orgin, ARA Direction, Out Hit, Mathf Infinity) (If (Hit Collator. Tags == "Stop" and End Stop) {Audio.Stop!! Stop} (Hit.collider.tag == "play" & amp; amp; amp; stop) {audio.play (); stop =! Stop}}}}}}
Comments
Post a Comment