コード例 #1
0
        /// <summary>
        /// Play an audio file inside an FMOD Event. Will play once without taking in 3D position
        /// </summary>
        /// <param name="audioFile">Audio file.</param>
        /// <param name="eventName">Event name.</param>
        public static void PlayOneShotProgrammerSound(string audioFile, string eventName)
        {
            audioFile = ExtensionsUtils.FindFile(audioFile);

            // Create the callback that will handle creating and destroying the programmer sound
            EVENT_CALLBACK callback = new EVENT_CALLBACK(ProgrammerEventCallback);

            // Create our one time event
            EventDescription eventDescription = RuntimeManager.GetEventDescription(eventName);
            EventInstance    eventInstance;

            eventDescription.createInstance(out eventInstance);

            // Set callback
            eventInstance.setCallback(callback);

            // Create our user data that we'll user later when playing the event
            ProgrammerSoundContext context = new ProgrammerSoundContext
            {
                file = audioFile,
                mode = MODE.CREATESAMPLE | MODE.LOOP_NORMAL | MODE.NONBLOCKING
            };

            // Create our pointer. It is unpinned when we get this data later
            GCHandle handle = GCHandle.Alloc(context, GCHandleType.Pinned);

            eventInstance.setUserData(GCHandle.ToIntPtr(handle));

            eventInstance.start();
            eventInstance.release();
        }
コード例 #2
0
        /// <summary>
        /// Play an audio file inside an FMOD event. Will play once at a given position
        /// </summary>
        /// <param name="audioFile">Audio file.</param>
        /// <param name="eventName">Event name.</param>
        /// <param name="position">Position.</param>
        public static void PlayOneShotProgrammerSound(string audioFile, string eventName, Vector3 position)
        {
            audioFile = ExtensionsUtils.FindFile(audioFile);

            EVENT_CALLBACK callback = new EVENT_CALLBACK(ProgrammerEventCallback);

            EventDescription eventDescription = RuntimeManager.GetEventDescription(eventName);
            EventInstance    eventInstance;

            eventDescription.createInstance(out eventInstance);

            eventInstance.set3DAttributes(RuntimeUtils.To3DAttributes(position));

            eventInstance.setCallback(callback);

            ProgrammerSoundContext context = new ProgrammerSoundContext();

            context.file = audioFile;
            context.mode = MODE.CREATESAMPLE | MODE._3D_LINEARSQUAREROLLOFF | MODE.LOOP_NORMAL | MODE.NONBLOCKING;

            GCHandle handle = GCHandle.Alloc(context, GCHandleType.Pinned);

            eventInstance.setUserData(GCHandle.ToIntPtr(handle));

            eventInstance.start();
            eventInstance.release();
        }
コード例 #3
0
    private void Start()
    {
        voiceCallback = new EVENT_CALLBACK(VoiceEventCallback);

        // create and pin voiceinfo in memory
        voiceInfo       = new VoiceStateInfo();
        voiceInfo.State = VoiceState.Silent;
        voiceInfoHandle = GCHandle.Alloc(voiceInfo, GCHandleType.Pinned);
    }
コード例 #4
0
    //private bool complete;

    void Start()
    {
        dialogueCallback = new EVENT_CALLBACK(DialogueEventCallback);
        portrait.sprite  = dialogArray[index].portrait;
        nameDisplay.text = dialogArray[index].name;
        textDisplay.text = "";
        PlayDialogue(dialogArray[index].dialogueSoundKey);
        StartCoroutine(Type());
    }
コード例 #5
0
        void Awake()
        {
            for (int i = 0; i < eventOptions.Length; i++)
            {
                string eventOption = eventOptions[i];

                if (!string.IsNullOrEmpty(eventOption))
                {
                    eventReferences.Add(eventOption);
                }
            }

            if (eventReferences.Count < 1)
            {
                Debug.LogWarning("Audio Object '" + gameObject.name + "' does not contain any valid FMOD event references.");
                return;
            }

            if (dontDestroyOnLoad)
            {
                isPersistent = true;
                DontDestroyOnLoad(this.gameObject);
            }

            if (listensToEvents)
            {
                AudioObjectMessenger.StartAudioObjectEvent += OnStartSoundEvent;
                AudioObjectMessenger.StopAudioObjectEvent  += OnStopSoundsEvent;

                if (isPersistent)
                {
                    AudioObjectMessenger.StopPersistentAudioObjectsEvent    += OnStopPersistentSoundsEvent;
                    AudioObjectMessenger.StopAllPersistantAudioObjectsEvent += OnStopAllPersistentSoundsEvent;
                }
            }
            else if (isPersistent)
            {
                AudioObjectMessenger.StopAllPersistantAudioObjectsEvent += OnStopAllPersistentSoundsEvent;
            }

            CreateIndexList();

            _usesResonanceAudioSource = usesResonanceAudioSource;

            if (_usesResonanceAudioSource && spatialAudioRoomAware)
            {
                instanceCreatedCallback = new EVENT_CALLBACK(EventInstanceCreatedCallback);
            }

            initializationSuccesfull = true;
        }
コード例 #6
0
        public static void PlayProgrammerSound(string audioFile, EventInstance instance)
        {
            // If we've already played this event and given it user data,
            // we only need to change the user data
            if (programmerInstances.Contains(instance))
            {
                // Get the user data that should be attached to the object
                IntPtr pointer;
                instance.getUserData(out pointer);

                GCHandle handle = GCHandle.FromIntPtr(pointer);
                ProgrammerSoundContext context = handle.Target as ProgrammerSoundContext;

                if (context != null)
                {
                    context.file = ExtensionsUtils.FindFile(audioFile);
                }
                // If there was no user data added, we'll have to add it here
                else
                {
                    context      = new ProgrammerSoundContext();
                    context.file = ExtensionsUtils.FindFile(audioFile);
                    context.mode = MODE.CREATESAMPLE | MODE.LOOP_NORMAL | MODE.NONBLOCKING;

                    handle = GCHandle.Alloc(context, GCHandleType.Pinned);
                    instance.setUserData(GCHandle.ToIntPtr(handle));

                    EVENT_CALLBACK callback = new EVENT_CALLBACK(ProgrammerEventCallback);
                    instance.setCallback(callback);
                }

                UnityEngine.Debug.Log("Changing User Data");
            }
            else
            {
                programmerInstances.Add(instance);

                ProgrammerSoundContext context = new ProgrammerSoundContext();
                context.file = ExtensionsUtils.FindFile(audioFile);
                context.mode = MODE.CREATESAMPLE | MODE.LOOP_NORMAL | MODE.NONBLOCKING;

                GCHandle handle = GCHandle.Alloc(context, GCHandleType.Pinned);
                instance.setUserData(GCHandle.ToIntPtr(handle));

                EVENT_CALLBACK callback = new EVENT_CALLBACK(ProgrammerEventCallback);
                instance.setCallback(callback);
            }
            instance.start();
        }
コード例 #7
0
    /*
     * Used to set a callback on an event instance that returns a EventCallbackData instance.
     * EventCallbackData can be used to simplify the process  of getting data from the callbacks.
     */
    public static void setCallback(
        EventInstance instance,
        Action <EventCallbackData> callback,
        EVENT_CALLBACK_TYPE callbackMask = EVENT_CALLBACK_TYPE.ALL)
    {
        EVENT_CALLBACK evCallback = (EVENT_CALLBACK_TYPE type, IntPtr eventInstance, IntPtr parameters) =>
        {
            try
            {
                EventCallbackData data = new EventCallbackData(type, eventInstance, parameters);
                callback(data);
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.LogError("Error occurred during event callback: " + ex.Message);
            }
            return(RESULT.OK);
        };

        evCallbacks.Add(evCallback);

        //set callback to lambda instance (whose lifetime SHOULD be the same as this class (forever))
        instance.setCallback(evCallback, callbackMask);
    }
コード例 #8
0
ファイル: fmod_studio.cs プロジェクト: supersjo/spacecowboy
 public RESULT setCallback(EVENT_CALLBACK callback)
 {
     return FMOD_Studio_EventDescription_SetCallback(rawPtr, callback);
 }
コード例 #9
0
ファイル: fmod_studio.cs プロジェクト: supersjo/spacecowboy
 public RESULT setCallback(EVENT_CALLBACK callback)
 {
     return FMOD_Studio_EventInstance_SetCallback(rawPtr, callback);
 }
コード例 #10
0
 public RESULT setCallback(EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask = EVENT_CALLBACK_TYPE.ALL)
 {
     return(EventInstance.FMOD_Studio_EventInstance_SetCallback(this.rawPtr, callback, callbackmask));
 }
コード例 #11
0
 public RESULT setCallback(EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask = EVENT_CALLBACK_TYPE.ALL)
 {
     return FMOD_Studio_EventInstance_SetCallback(rawPtr, callback, callbackmask);
 }
コード例 #12
0
            private EVENT_CALLBACK cachedCallback; // cached to prevent gc free-ing the callback delegate

            public EventInstance()
            {
                cachedCallback = wrapperCallback;
            }
コード例 #13
0
 public RESULT setCallback(EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask = EVENT_CALLBACK_TYPE.ALL)
 {
     return(FMOD_Studio_EventDescription_SetCallback(handle, callback, callbackmask));
 }
コード例 #14
0
 public RESULT setCallback(EVENT_CALLBACK callback, IntPtr userdata)
 {
     return FMOD_Event_SetCallback(eventraw, callback, userdata);
 }
コード例 #15
0
 public RESULT setCallback(EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask = EVENT_CALLBACK_TYPE.ALL)
 {
     return(EventDescription.FMOD_Studio_EventDescription_SetCallback(this.rawPtr, callback, callbackmask));
 }
コード例 #16
0
 private static extern RESULT FMOD_Event_SetCallback(IntPtr _event, EVENT_CALLBACK callback, IntPtr userdata);
コード例 #17
0
 private static extern RESULT FMOD_Studio_EventDescription_SetCallback(IntPtr eventdescription, EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask);
コード例 #18
0
 static public void AddListener(GameObject obj, UGUIEventType evtType, EVENT_CALLBACK <AxisEventData> func)
 {
     AddListenerAsDelegate(obj, evtType, func);
 }
コード例 #19
0
            private EVENT_CALLBACK cachedCallback; // cached to prevent gc free-ing the callback delegate

            public EventInstance()
            {
                cachedCallback = wrapperCallback;
            }
コード例 #20
0
 private static extern RESULT FMOD_Studio_EventDescription_SetCallback(IntPtr eventdescription, EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask);
コード例 #21
0
 private static extern RESULT FMOD_Studio_EventInstance_SetCallback(IntPtr _event, EVENT_CALLBACK callback);
コード例 #22
0
 private static extern RESULT FMOD_Studio_EventInstance_SetCallback          (IntPtr _event, EVENT_CALLBACK callback, EVENT_CALLBACK_TYPE callbackmask);
コード例 #23
0
 public static void AddListener(GameObject obj, UGUIEventType evtType, EVENT_CALLBACK<AxisEventData> func)
 {
     AddListenerAsDelegate(obj, evtType, func);
 }