- Home /
              This post has been wikified, any user with enough reputation can edit it. 
            
 
             
               Question by 
               uanmanarmy · Feb 09, 2014 at 05:41 PM · 
                guigetcomponentaudioclipvolumeaccessing from any script  
              
 
              How to access an AudioClipVariable from other Script c#
Hello guys .
I have a question . I have a menu with Exit button and when my mouse is on it a specific sound turns on . Now at my bottom right part of my screen I have a button . I added this button for switching on/off sfx to the Exit button .
This is my On/Off button Script
 using UnityEngine;
 using System.Collections;
 
 public class SFXButtonScript : MonoBehaviour {
 
     public Texture2D normalTex;
     public Texture2D hoverTex;
 
     void Start () 
     {
 
 
     }
     void OnMouseDown()
     {
         if (guiTexture.texture == normalTex)
         {
             //if (Input.GetMouseButton (0) && guiTexture.HitTest (Input.mousePosition))
             guiTexture.texture = hoverTex;
             Debug.Log ("OFF");
         }
         else if (guiTexture.texture = hoverTex)
             //if (Input.GetMouseButton (0))// && guiTexture.HitTest (Input.mousePosition))
         {
             guiTexture.texture = normalTex;
             Debug.Log ("on");
         }
     }
 
 }
and this is my Exit button Script
 using UnityEngine;
 using System.Collections;
 
 public class ExitButtonScript : MonoBehaviour {
         
         public Texture2D normalTex;
         public Texture2D hoverTex;
         public AudioClip menuhover;
 
         void OnMouseEnter()
         {
             Sound (menuhover);
             guiTexture.texture = hoverTex;
         }
         void OnMouseExit()
         {
             guiTexture.texture = normalTex;
         }
         void OnMouseDown()
         {
             Application.Quit();
         }
         public  void Sound (AudioClip sound)
         {
             audio.clip = sound;
             audio.Play ();
         }
         
     }
How do i connect my sound from ExitButtonScript to my SFXButtonScript . So when i make my SFX button ON ,the audio.volume of audioclip atached to the Exit Button to be 1 , and zero otherwise. ?
Any help will be appreciated .
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                