示例#1
0
	// Use this for initialization
	
	
	// Update is called once per frame
	/*void Update () {
		
		if(Input.GetKeyDown (KeyCode.Space))
			//GetComponent<ParticleSystem>().Emit(300);
			photonView.RPC("DoExploder",PhotonTargets.All, new object[]{1500});
		
		
		else if(Input.GetKeyDown (KeyCode.Return))
			//GetComponent<ParticleSystem>().Emit(1500);
			photonView.RPC("DoExploder",PhotonTargets.All, new object[]{1500});
		
	}
	*/

	public void PlaySound(AudioClip clip){
		stringclip = clip.ToString();
		Debug.Log (stringclip);

		photonView.RPC("PlaySoundHandler",PhotonTargets.All, null);

		//explosions
		photonView.RPC("DoExploder",PhotonTargets.All, new object[]{15});
	}
示例#2
0
 public string GetDescription()
 {
     if (audioClipRef == null)
     {
         return(audioClipVal != null?audioClipVal.ToString() : "Null");
     }
     else
     {
         return(audioClipRef.Key);
     }
 }
示例#3
0
    public static AudioSource CreateClip(AudioClip clip, float volume, float pitch)
    {
        if (GameObject.Find(clip.name) != null)
            return null;

        AudioSource source = CreateSource();
        source.clip = clip;
        source.volume = volume;
        source.pitch = pitch;
        source.spatialBlend = 0;
        source.gameObject.name = clip.name;

        Debug.Log((GameObject.Find(clip.ToString()) == null) + " " + clip.ToString() );
        source.Play();

        // Registrar la fuente de sonido
        AudioSettings.RegisterClip(source);

        return source;
    }
示例#4
0
    void Awake()
    {
        audioSource = GetComponent<AudioSource>();
        sound = audioSource.clip;
        argument = sound.ToString();
        string newstring = argument.Replace(" (UnityEngine.AudioClip)", "");
        argument = newstring;

        AudioManager.AddAudioToDictionary(argument, gameObject);
        AudioManager.AddListener(audioEvent, sound3D);
    }
示例#5
0
    public void PlayOneShot(AudioClip clip, float volume = 1f)
    {
        if(audio != null)
        {
            if(clip !=null && clip.isReadyToPlay)
            {
                audio.PlayOneShot(clip, volume);
            }
            else
            {
                Log.i ("clicp " + clip.ToString() + "is not ready to play...");
            }

        }
        else
        {
            Log.i("audio null...");
        }
    }
示例#6
0
文件: Audio3D.cs 项目: ProfAF/PAX
    void Awake()
    {
        // audioSource gets everything AudioSource has.
        // Then the sound is assigned to audioSource.clip
        // argument is assigned to sound(AudioClip) to a string.
        // define newstring assigned to argument to replace the old string with another string, but my question, is how does it know the old string is (UnityEngine.AudioClip)
        // then argument is assigned to the newstring, which will produce audioClip name

        audioSource = GetComponent<AudioSource>();
        sound = audioSource.clip;
        argument = sound.ToString();
        string newstring = argument.Replace(" (UnityEngine.AudioClip)", "");
        argument = newstring;

        // For Triggers
        // For 3D audio, you must step in the trigger box for it to play 3D

        AudioManager.AddAudioToDictionary(argument, gameObject);
        AudioManager.AddListener(audioEvent, sound3D);
    }
 //Null test for arrays
 private AudioClip NullTest(AudioClip[] TestArray, int i)
 {
     if( (i + 1) <= TestArray.Count())
     {
         if (TestArray[i])
             return TestArray[i];
         else
             return ErrorSound;
     }
     else
     {
         Debug.Log("ERROR: No Audiosource at: " + TestArray.ToString() +" "+ i.ToString());
         return ErrorSound;
     }
 }