コード例 #1
0
        public override void OnEnd(GameObject go)
        {
            base.OnEnd(go);
            CustomSound component = (CustomSound)go.GetComponent <CustomSound>();

            if (!Object.op_Inequality((Object)component, (Object)null))
            {
                return;
            }
            Object.Destroy((Object)component);
        }
コード例 #2
0
        public override void OnStart(GameObject go)
        {
            if (Object.op_Equality((Object)go, (Object)null) || string.IsNullOrEmpty(this.CueID))
            {
                return;
            }
            CustomSound customSound = (CustomSound)go.GetComponent <CustomSound>();

            if (Object.op_Equality((Object)customSound, (Object)null))
            {
                customSound = (CustomSound)go.AddComponent <CustomSound>();
            }
            customSound.type        = this.SoundType;
            customSound.cueID       = this.CueID;
            customSound.LoopFlag    = false;
            customSound.StopSec     = 0.0f;
            customSound.PlayOnAwake = false;
            customSound.Play();
        }
コード例 #3
0
    /// <summary>
    /// DEPRECATED
    /// </summary>
    /// <param name="sound">Sound.</param>
    void SpawnAudioObject(CustomSound sound)
    {
        GameObject g = new GameObject();

        g.name = "AudioClip" + name + sources.Count;
        g.AddComponent <AudioSource> ();
        AudioSource source = g.GetComponent <AudioSource> ();

        source.clip = sound.clip;
        if (sound.type == SoundsType.Ambient)
        {
            source.outputAudioMixerGroup = music;
        }
        if (sound.type == SoundsType.Effect || sound.type == SoundsType.Conversation)
        {
            source.outputAudioMixerGroup = sfx;
        }
        source.Play();
        sources.Add(g);
    }
コード例 #4
0
 public void PlaySound(CustomSound sound, bool doRandomPitch)
 {
     for (int i = 0; i < audioSources.Length; i++)
     {
         if (audioSources[i].isPlaying == false)
         {
             audioSources[i].clip = sound.clip;
             if (doRandomPitch)
             {
                 audioSources[i].pitch = Random.Range(0.95f, 1.05f);
             }
             else
             {
                 audioSources[i].pitch = 1.0f;
             }
             audioSources[i].volume = sound.volume;
             audioSources[i].Play();
             return;
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// DEPRECATED
 /// </summary>
 /// <param name="sound">Sound.</param>
 void SpawnAudioObject(CustomSound sound)
 {
     GameObject g = new GameObject ();
     g.name = "AudioClip" + name + sources.Count;
     g.AddComponent<AudioSource> ();
     AudioSource source = g.GetComponent<AudioSource> ();
     source.clip = sound.clip;
     if(sound.type == SoundsType.Ambient)
     {
         source.outputAudioMixerGroup = music;
     }
     if (sound.type == SoundsType.Effect || sound.type == SoundsType.Conversation) {
         source.outputAudioMixerGroup = sfx;
     }
     source.Play ();
     sources.Add (g);
 }
コード例 #6
0
    // Use this for initialization

    void Awake()
    {
        instance = this;
    }