Example #1
0
    public void Play()
    {
        if (started)
        {
            if (paused)
            {
                Resume();
            }
            else
            {
                Debug.LogError("Already Playing! ", this);
            }

            return;
        }

        if (soundClip == null || soundSystem == null || soundClip.audioClip == null)
        {
            Debug.LogError("Asked for playing SoundSource, but no null is given! ", this);
            Destroy(this);
            return;
        }

        // Create Sound Source
        audioSource      = soundClip.GetSourceObject().AddComponent <AudioSource>();
        audioSource.clip = soundClip.audioClip;
        audioSource.loop = loopPlay;

        // Apply Sound Property
        soundProperty = soundSystem.GetProperty(soundType);
        UpdateAudioSource();

        // Start Playing
        soundSystem.AddPlayingSource(this);
        audioSource.Play();
        started = true;
    }