Exemplo n.º 1
0
        // -------------------------------------------------------------------------------
        // PlaySound
        // -------------------------------------------------------------------------------
        private static SoundObject PlaySound(SoundTemplate tmpl)
        {
            if (tmpl == null)
            {
                return(null);
            }
            SoundObject sound = ((GameObject)GameObject.Instantiate(tmpl.soundObjectPrefab)).GetComponent <SoundObject>();

            sound.SetClip(tmpl);
            return(sound);
        }
Exemplo n.º 2
0
        // -------------------------------------------------------------------------------
        // Play
        // -------------------------------------------------------------------------------
        public static SoundObject Play(SoundTemplate tmpl, Vector3 pos)
        {
            SoundObject sound = PlaySound(tmpl);

            if (sound == null)
            {
                return(null);
            }

            sound.transform.position = pos;
            return(sound);
        }
Exemplo n.º 3
0
 // -------------------------------------------------------------------------------
 // SetClip
 // -------------------------------------------------------------------------------
 public void SetClip(SoundTemplate sound)
 {
     if (source == null)
     {
         source = GetComponent <AudioSource>();
     }
     source.clip         = sound.clip;
     source.volume       = sound.volume * SoundController.GetVolume();
     source.spatialBlend = sound.is2d ? 0 : 1;
     source.Play();
     Destroy(this.gameObject, sound.clip.length + 0.5f);
 }
Exemplo n.º 4
0
        // -------------------------------------------------------------------------------
        // Play
        // -------------------------------------------------------------------------------
        public static SoundObject Play(SoundTemplate tmpl, Transform tran)
        {
            SoundObject sound = PlaySound(tmpl);

            if (sound == null)
            {
                return(null);
            }

            sound.transform.parent        = tran;
            sound.transform.localPosition = Vector3.zero;
            return(sound);
        }
Exemplo n.º 5
0
        // -------------------------------------------------------------------------------
        // Play
        // -------------------------------------------------------------------------------
        public static SoundObject Play(SoundTemplate tmpl)
        {
            SoundObject sound = PlaySound(tmpl);

            return(sound);
        }