Beispiel #1
0
    void OnEnable()
    {
        if (instance == null || instance == this)
        {
            if (activeAudioListener == null)
            {
                activeAudioListener = FindActiveListener();
            }

            instance            = this;
            _inAudioEventWorker = GetComponentInChildren <InAudioEventWorker>();
            runtimeData         = GetComponentInChildren <InRuntimeAudioData>();
            BankLoader.LoadAutoLoadedBanks();
            runtimeData.UpdateEvents(InAudioInstanceFinder.DataManager.EventTree);
            //AudioBusVolumeHelper.UpdateCombinedVolume(InAudioInstanceFinder.DataManager.BusTree);
            DontDestroyOnLoad(transform.gameObject);

            if (InAudioInstanceFinder.DataManager != null && InAudioInstanceFinder.DataManager.BusTree != null)
            {
                var busRoot = InAudioInstanceFinder.DataManager.BusTree;
                TreeWalker.ForEach(busRoot, b => b.NodesInBus = new List <InPlayer>());
                busRoot.Dirty = true;
                AudioBusVolumeHelper.InitVolumes(busRoot);
                AudioBusVolumeHelper.UpdateVolumes(InAudioInstanceFinder.DataManager.BusTree);
            }
        }
        else
        {
            Object.Destroy(transform.gameObject);
        }
    }
 private void DrawRightSide(Rect area)
 {
     if (treeDrawer.SelectedNode != null)
     {
         AudioBusDrawer.Draw(treeDrawer.SelectedNode);
         AudioBusVolumeHelper.SetBusVolumes(InstanceFinder.DataManager.BusTree);
     }
 }
Beispiel #3
0
    void OnLevelWasLoaded()
    {
        var root = InAudioInstanceFinder.DataManager.BusTree;

        root.Dirty = true;
        AudioBusVolumeHelper.UpdateVolumes(root);
        if (activeAudioListener == null)
        {
            activeAudioListener = FindActiveListener();
        }
    }
Beispiel #4
0
    void Update()
    {
        AudioBusVolumeHelper.UpdateDucking(InAudioInstanceFinder.DataManager.BusTree);
        AudioBusVolumeHelper.UpdateVolumes(InAudioInstanceFinder.DataManager.BusTree);

        var controllerPool = InAudioInstanceFinder.RuntimePlayerControllerPool;

        if (controllerPool != null)
        {
            controllerPool.DelayedRelease();
        }

        var playerPool = InAudioInstanceFinder.InRuntimePlayerPool;

        if (playerPool != null)
        {
            playerPool.DelayedRelease();
        }
    }
Beispiel #5
0
    /*Internal systems*/
    #region Internal system

    private void HandleEventAction(GameObject controllingObject, AudioEventAction eventData, GameObject attachedTo, Vector3 playAt = new Vector3())
    {
        InAudioNode audioNode; //Because we can't create variables in the scope of the switch with the same name
        InEventBankLoadingAction bankLoadingData;

        if (eventData.Target == null && eventData.EventActionType != EventActionTypes.StopAll)
        {
            InDebug.MissingActionTarget(controllingObject, eventData);
            return;
        }

        switch (eventData.EventActionType)
        {
        case EventActionTypes.Play:
            var audioPlayData = ((InEventAudioAction)eventData);
            audioNode = audioPlayData.Node;
            if (audioNode != null)
            {
                if (attachedTo != null)
                {
                    _inAudioEventWorker.PlayAttachedTo(controllingObject, audioNode, attachedTo, audioPlayData.Fadetime, audioPlayData.TweenType);
                }
                else
                {
                    _inAudioEventWorker.PlayAtPosition(controllingObject, audioNode, playAt, audioPlayData.Fadetime, audioPlayData.TweenType);
                }
            }
            break;

        case EventActionTypes.Stop:
            var data = ((InEventAudioAction)eventData);
            audioNode = data.Node;
            _inAudioEventWorker.StopByNode(controllingObject, audioNode, data.Fadetime, data.TweenType);
            break;

        case EventActionTypes.StopAll:
            var stopAlLData = ((InEventAudioAction)eventData);
            _inAudioEventWorker.StopAll(controllingObject, stopAlLData.Fadetime, stopAlLData.TweenType);
            break;

        case EventActionTypes.Break:
            audioNode = ((InEventAudioAction)eventData).Node;
            _inAudioEventWorker.Break(controllingObject, audioNode);
            break;

        case EventActionTypes.SetBusVolume:
            var busData = eventData as InEventBusAction;
            if (busData != null && busData.Bus != null)
            {
                AudioBusVolumeHelper.SetTargetVolume(busData.Bus, busData.Volume, busData.VolumeMode, busData.Duration, busData.FadeCurve);
            }
            break;

        case EventActionTypes.BankLoading:
            bankLoadingData = eventData as InEventBankLoadingAction;
            if (bankLoadingData != null)
            {
                if (bankLoadingData.LoadingAction == BankHookActionType.Load)
                {
                    BankLoader.Load(bankLoadingData.BankLink);
                }
                else
                {
                    BankLoader.Unload(bankLoadingData.BankLink);
                }
            }
            break;

        case EventActionTypes.StopAllInBus:
            busData = eventData as InEventBusAction;
            if (busData != null && busData.Bus != null)
            {
                StopAllNodeInBus(busData.Bus);
            }
            break;

        case EventActionTypes.SetBusMute:
            var busMuteData = eventData as InEventBusMuteAction;
            if (busMuteData != null && busMuteData.Bus != null)
            {
                AudioBusVolumeHelper.MuteAction(busMuteData.Bus, busMuteData.Action);
            }
            break;

        default:
            InDebug.UnusedActionType(gameObject, eventData);
            break;
        }
    }
Beispiel #6
0
    private void HandleEventAction(GameObject controllingObject, AudioEventAction eventData, GameObject attachedTo, Vector3 playAt = new Vector3())
    {
        AudioNode       audioNode; //Because we can't create variables in the scope of the switch with the same name
        EventBankAction bankData;

        switch (eventData.EventActionType)
        {
        case EventActionTypes.Play:
            audioNode = ((EventAudioAction)eventData).Node;
            if (attachedTo != null)
            {
                audioPlayer.Play(controllingObject, audioNode, attachedTo);
            }
            else
            {
                audioPlayer.PlayAtPosition(controllingObject, audioNode, playAt);
            }
            break;

        case EventActionTypes.Stop:
            audioNode = ((EventAudioAction)eventData).Node;
            audioPlayer.StopByNode(controllingObject, audioNode);
            break;

        case EventActionTypes.StopAll:
            audioPlayer.StopAll(controllingObject);
            break;

        case EventActionTypes.Break:
            audioNode = ((EventAudioAction)eventData).Node;
            audioPlayer.Break(controllingObject, audioNode);
            break;

        case EventActionTypes.SetBusVolume:
            var busData = eventData as EventBusAction;
            if (busData != null && busData.Bus != null)
            {
                AudioBusVolumeHelper.SetTargetVolume(busData.Bus, busData.Volume, busData.VolumeMode);
            }
            break;

        case EventActionTypes.LoadBank:
            bankData = eventData as EventBankAction;
            if (bankData != null)
            {
                BankLoader.Load(bankData.BankLink);
            }
            break;

        case EventActionTypes.UnloadBank:
            bankData = eventData as EventBankAction;
            if (bankData != null)
            {
                BankLoader.Unload(bankData.BankLink);
            }
            break;

        case EventActionTypes.StopAllInBus:
            busData = eventData as EventBusAction;
            if (busData != null && busData.Bus != null)
            {
                StopAllNodeInBus(busData.Bus);
            }
            break;
        }
    }
Beispiel #7
0
 void FixedUpdate()
 {
     AudioBusVolumeHelper.UpdateDirtyBusses(InstanceFinder.DataManager.BusTree);
 }