Beispiel #1
0
        private bool PlayProtocol(string key, string dialogueName, float overrideDuration)
        {
            eventInstance = FMODUnity.RuntimeManager.CreateInstance(masterVoiceoverEvent);

            if (!eventInstance.isValid())
            {
                return(false);
            }

            GCHandle stringHandle = GCHandle.Alloc(key, GCHandleType.Pinned);

            eventInstance.setUserData(GCHandle.ToIntPtr(stringHandle));
            eventInstance.setCallback(voiceoverCallback);

            if (is3D)
            {
                Transform transformToFollow;

                if (followTransform != null)
                {
                    transformToFollow = followTransform;
                }
                else
                {
                    transformToFollow = gameObject.transform;
                }

                // If the followed game object has a rigidbody, retrieve it and pass it to FMODUnity Runtimemanager for velocity updates.
                Rigidbody rb = transformToFollow.gameObject.GetComponent <Rigidbody>();

                FMODUnity.RuntimeManager.AttachInstanceToGameObject(eventInstance, transformToFollow, rb);

                if (spatialAudioRoomAware && SpatialAudioManager.Instance != null)
                {
                    SpatialAudioManager.Instance.RegisterRoomAwareInstance(eventInstance, transformToFollow, maxDistance, initialRoom);
                }
            }

            isSpeaking      = true;
            currentDialogue = dialogueName;

            if (overrideDuration >= 0)
            {
                StartCoroutine(WaitBeforeDialogueRelease(overrideDuration));
                coroutineRunning = true;
            }

            eventInstance.start();

            return(true);
        }
Beispiel #2
0
        public void StartMusic(string name, float volume)
        {
            musicEventName = name;
            musicVolume    = volume;

            musicEvent = FmodFacade.instance.CreateFmodEventInstance(FmodFacade.instance.GetFmodMusicEventFromDictionary(name));

            musicEvent.setCallback(beatCallback,
                                   FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_BEAT
                                   | FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_MARKER
                                   | FMOD.Studio.EVENT_CALLBACK_TYPE.STARTED
                                   );

            // Pass the object through the userdata of the instance
            musicEvent.setUserData(GCHandle.ToIntPtr(timelineHandle));

            FmodFacade.instance.PlayFmodEvent(musicEvent, volume);
            isMusicPlaying = true;
        }
Beispiel #3
0
 /// <summary>
 /// Stops the passed in fmod event
 /// </summary>
 /// <param name="fmodEvent"> The name of the event we want to stop </param>
 public void StopFmodEvent(FMOD.Studio.EventInstance fmodEvent)
 {
     fmodEvent.setUserData(IntPtr.Zero);
     fmodEvent.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
     fmodEvent.release();
 }