public AudioChannelPool(uint channelCount)
        {
            _AudioChannels = new AudioChannel[channelCount];

            GameObject             parentObject      = new GameObject("Audio Channels");
            UnityCallbackBehaviour callbackBehaviour = parentObject.AddComponent <UnityCallbackBehaviour>();

            Object.DontDestroyOnLoad(parentObject);
            for (int i = 0; i < _AudioChannels.Length; i++)
            {
                _AudioChannels[i] = new AudioChannel(parentObject.transform, callbackBehaviour, i + 1);
            }
        }
Beispiel #2
0
        public AudioChannel(Transform parent, UnityCallbackBehaviour callbacks, int channelNumber = -1)
        {
            _Callbacks         = callbacks;
            _ChannelNumber     = channelNumber;
            _GameObject        = new GameObject($"Audio Channel {channelNumber}");
            _TransformFollower = new TransformFollower(callbacks, _GameObject.transform);

            if (parent)
            {
                _GameObject.transform.SetParent(parent);
            }
            _GameObject.SetActive(false);

            _AudioSource = _GameObject.AddComponent <AudioSource>();
        }
Beispiel #3
0
 public TransformFollower(UnityCallbackBehaviour callbackBehaviour, Transform source)
 {
     _Transform         = source;
     _CallbackBehaviour = callbackBehaviour;
 }