Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        _prefabManager    = FindObjectOfType <PrefabManager>();
        _projectilePrefab = _prefabManager.GetProjectilePrefab(Params);
        _soundManager     = FindObjectOfType <SoundManager>();
        AudioClip shotSoundClip = ResourceUtil.LoadSound(Params.ShootSound);

        _soundManager.AddAudioSource(gameObject.GetInstanceID(), shotSoundClip);
    }
    public void SetAudioSource(Transform obj, out AudioSource sourceToHookUp)
    {
        SoundManager.AddAudioSource(obj);

        if (obj.GetComponents <AudioSource>().Length > 1)
        {
            AudioSource[] audioSources;
            audioSources   = obj.GetComponents <AudioSource>();
            sourceToHookUp = audioSources[audioSources.Length - 1];
            sourceToHookUp.spatialBlend = 1;
        }
        else
        {
            sourceToHookUp = obj.GetComponent <AudioSource>();
            sourceToHookUp.spatialBlend = 1;
        }
    }