public static ReverbSettings SaveSettings(ReverbSettings toSave)
    {
        if (toSave != null)
        {
            ReverbSettings   newSettings  = ReverbSettings.Create(toSave);
            GlobalReverbZone globalReverb = GameObject.FindObjectOfType(typeof(GlobalReverbZone)) as GlobalReverbZone;

            newSettings.beforeSerializePresets();
#if UNITY_EDITOR
            string settingsAssetPath = ReverbSettings.GetSettingsAssetPath();
            if (AssetDatabase.Contains(toSave) == true)
            {
                AssetDatabase.DeleteAsset(settingsAssetPath);
            }
            AssetDatabase.CreateAsset(newSettings, settingsAssetPath);
            AssetDatabase.SaveAssets();

            if (globalReverb != null)
            {
                newSettings.afterDeserializePresets();
                globalReverb.settings  = newSettings;
                LOADED_REVERB_SETTINGS = globalReverb.settings;
                if (EditorApplication.isPlaying || EditorApplication.isPaused)
                {
                    FmodEventSystem.GetReverbManager().UpdateGlobalReverb();
                }
            }
#endif
        }
        else
        {
            Debug.LogError("FMOD_Unity: ReverbSettings: Null reverb settings");
        }
        return(LOADED_REVERB_SETTINGS);
    }
Exemple #2
0
    public void OnGUI()
    {
        this.title = "Active Reverb Zones";
        if (Application.isPlaying == false)
        {
            EditorGUILayout.HelpBox("Application not playing", MessageType.Info, true);
            Repaint();
            return;
        }
        List <FmodReverbZone> zoneStack = FmodEventSystem.GetReverbManager().GetReverbZoneStack();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Zone name", GUILayout.Width(3 * this.position.width / 10));
        EditorGUILayout.LabelField("Reverb preset", GUILayout.Width(3 * this.position.width / 10));
        EditorGUILayout.LabelField("Priority", GUILayout.Width(2 * this.position.width / 10));
        EditorGUILayout.LabelField("Fade time", GUILayout.Width(2 * this.position.width / 10));
        EditorGUILayout.EndHorizontal();

        foreach (FmodReverbZone zone in zoneStack)
        {
            if (zone != null)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(zone.name, GUILayout.Width(3 * this.position.width / 10));
                EditorGUILayout.LabelField(zone.GetReverb().getName(), GUILayout.Width(3 * this.position.width / 10));
                EditorGUILayout.LabelField(zone.Priority.ToString(), GUILayout.Width(2 * this.position.width / 10));
                EditorGUILayout.LabelField(zone.fadeTime.ToString(), GUILayout.Width(2 * this.position.width / 10));
                EditorGUILayout.EndHorizontal();
            }
        }
        Repaint();
    }
Exemple #3
0
 public static void getEventSystem(FmodEventSystemHandle handle)
 {
     if (handle.getEventSystem() == null)
     {
         if (m_holder == null)
         {
             m_holder = GameObject.FindObjectOfType(typeof(FmodEventSystemHolder)) as FmodEventSystemHolder;
             if (m_holder == null)
             {
                 UnityEngine.GameObject holderObject = new UnityEngine.GameObject("FmodEventSystemHolder");
                 holderObject.AddComponent(typeof(FmodEventSystemHolder));
                 m_holder = holderObject.GetComponent <FmodEventSystemHolder>();
             }
         }
         if (m_holder == null)
         {
             Debug.LogError("Could not find FmodEventSystemHolder; FMOD integration will not work");
         }
         else
         {
             if (m_FmodEventSystem == null)
             {
                 m_FmodEventSystem = new FmodEventSystem();
                 m_FmodEventSystem._createEventSystem();
                 m_holder.SetFmodEventSystemHandle(new FmodEventSystemHandle());
             }
             handle.setEventSystem(m_FmodEventSystem);
             GetReverbManager();
         }
     }
 }
 public FmodEventSystemHandle()
 {
     FmodEventSystem.getEventSystem(this);
     if (m_eventSystem != null)
     {
         m_nbHandles++;
     }
 }
 public bool setEventSystem(FmodEventSystem system)
 {
     if (system == null || m_eventSystem != null) {
         return (false);
     }
     m_eventSystem = system;
     return (false);
 }
 public bool setEventSystem(FmodEventSystem system)
 {
     if (system == null || m_eventSystem != null)
     {
         return(false);
     }
     m_eventSystem = system;
     return(false);
 }
 public void Update()
 {
     if (m_handle != null)
     {
         FmodEventSystem system = m_handle.getEventSystem();
         if (system != null)
         {
             system.updateSystem();
         }
     }
 }
Exemple #8
0
    public FMOD.RESULT getEvent(FmodEventAudioSource wantedSource)
    {
        if (wantedSource == null || wantedSource.getSource() == null)
        {
            Debug.LogError(getErrorPrefix() + "Invalid data was passed for FmodEventAudioSource");
            return(FMOD.RESULT.ERR_EVENT_FAILED);
        }
        if (wantedSource.getSource() != m_event)
        {
            Debug.LogError(getErrorPrefix() + "FmodEventAudioSource tried to load event '" + wantedSource.getSource().getName() + "' from the bad pool.");
            return(FMOD.RESULT.ERR_EVENT_FAILED);
        }
        if (wantedSource.isRuntimeEventLoaded())
        {
            return(FMOD.RESULT.OK);
        }
        if (m_availableEvents.Count > 0)
        {
            // below, we take back an event that was loaded and unused
            FMOD.Event oldestEvent = m_availableEvents[0];
            m_availableEvents.RemoveAt(0);

            wantedSource.SetEvent(oldestEvent);
            if (m_activeSources.Contains(wantedSource))
            {
                Debug.LogWarning(getErrorPrefix() + "FmodEventAudioSource '" + wantedSource.name + "' loaded an event but was already active. Are you sure this should happen ?");
            }
            else
            {
                m_activeSources.Add(wantedSource);
            }
        }
        else
        {
            // here we have no event loaded, so we must load a new one.
            using (FmodEventSystemHandle handle = new FmodEventSystemHandle()) {
                FmodEventSystem system = handle.getEventSystem();

                if (system != null && system.wasCleaned() == false)
                {
                    FMOD.RESULT result = FMOD.RESULT.OK;

                    result = system.loadEventFromFile(wantedSource);
                    if (result == FMOD.RESULT.OK)
                    {
                        m_activeSources.Add(wantedSource);
                    }
                    return(result);
                }
            }
        }
        return(FMOD.RESULT.OK);
    }
 protected virtual void Dispose(bool disposing)
 {
     if (m_eventSystem != null)
     {
         if (m_nbHandles == 0)
         {
             Debug.LogWarning("FMOD_Unity: FmodEventSystemHandle: An event system is still referenced but there is no handle on it ! This should not happen !");
         }
         else
         {
             if (--m_nbHandles == 0 && Application.isEditor)
             {
                 m_eventSystem.clean();
                 m_eventSystem = null;
             }
         }
     }
 }
Exemple #10
0
    private void clean(bool checkForHandles)
    {
        int nbEventSystemHandles = FmodEventSystemHandle.NbHandles;

        if (m_eventSystem != null &&
            (checkForHandles == false || nbEventSystemHandles <= 1))
        {
            List <FmodEventAudioSource> tmpList = m_eventPoolManager.getAllActiveSources();
            foreach (FmodEventAudioSource src in tmpList)
            {
                if (src != null)
                {
                    src.Clean();
                }
            }
            if (m_musicSystem != null)
            {
                m_musicSystem.release();
                m_musicSystem = null;
            }
            if (_unloadAllFiles())
            {
                ERRCHECK(m_eventSystem.unload());
            }
            if (m_eventSystem != null)
            {
                ERRCHECK(m_eventSystem.release());
                m_eventSystem = null;
            }

            if (m_system != null)
            {
                ERRCHECK(m_system.release());
                m_system = null;
            }

            m_eventSystemWasCleaned = true;
            m_eventSystemWasInit    = false;
            WasCleaned = true;
            FmodEventSystem.m_FmodEventSystem = null;
        }
    }
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string str in importedAssets)
        {
            if (str.EndsWith(@".fev"))
            {
                if (File.Exists(str + @".asset"))
                {
                    FmodEventAsset newAsset = FmodEventAsset.CreateInstance("FmodEventAsset") as FmodEventAsset;
                    FmodEventAsset oldAsset = AssetDatabase.LoadAssetAtPath(str + @".asset", typeof(FmodEventAsset)) as FmodEventAsset;

                    newAsset.Initialize(str);
                    UpdateEventAsset(oldAsset, newAsset);
                    newAsset.CreateAsset(str);
                    AssetDatabase.SaveAssets();
                    CheckForRemainsOfDeletedParameters();
                    FmodEventSystem.ClearHolder();
                }
                else
                {
                    FmodEventAsset asset = FmodEventAsset.CreateInstance("FmodEventAsset") as FmodEventAsset;
                    asset.Initialize(str);
                    asset.CreateAsset(str);
                    FmodEventSystem.ClearHolder();
                }
            }
            else if (Application.isPlaying && Application.isEditor &&
                     (str.EndsWith(@".cs") || str.EndsWith(@".js")))
            {
                                 #if UNITY_EDITOR
                EditorApplication.isPlaying = false;                         // we are forced to stop the application in the editor at this point, or else Mono will rebuild the app and we'll lose the managed memory. Unfortunately, the C++ application will still be running and we won't be able to come back.
                Debug.LogWarning("FMOD_Unity : Forced to leave the application because source code was about to be built");
                                #endif
            }
        }
    }
    public void OnEnable()
    {
        FmodEventSystemHolder holder = FmodEventSystem.getEventSystemHolder();

        if (holder != null && holder != this)
        {
            Component[] comps = gameObject.GetComponents <Component>();

            if (comps.Length == 2)               // if only transform and holder comps, we can delete the gameObject
            {
                Destroy(gameObject);
            }
            else                 // if there are any other components, we can't delete the gameObject, but we can delete the comp
            {
                Destroy(this);
            }
        }
        else
        {
#if UNITY_EDITOR
            EditorApplication.playmodeStateChanged += clean;
#endif
        }
    }
 public static void getEventSystem(FmodEventSystemHandle handle)
 {
     if (handle.getEventSystem() == null) {
         if (m_holder == null) {
             m_holder = GameObject.FindObjectOfType(typeof(FmodEventSystemHolder)) as FmodEventSystemHolder;
             if (m_holder == null) {
                 UnityEngine.GameObject holderObject = new UnityEngine.GameObject("FmodEventSystemHolder");
                 holderObject.AddComponent(typeof(FmodEventSystemHolder));
                 m_holder = holderObject.GetComponent<FmodEventSystemHolder>();
             }
         }
         if (m_holder == null) {
             Debug.LogError("Could not find FmodEventSystemHolder; FMOD integration will not work");
         } else {
             if (m_FmodEventSystem == null) {
                 m_FmodEventSystem = new FmodEventSystem();
                 m_FmodEventSystem._createEventSystem();
                     m_holder.SetFmodEventSystemHandle(new FmodEventSystemHandle());
             }
             handle.setEventSystem(m_FmodEventSystem);
             GetReverbManager();
         }
     }
 }
    private void clean(bool checkForHandles)
    {
        int nbEventSystemHandles = FmodEventSystemHandle.NbHandles;
        if (m_eventSystem != null &&
            (checkForHandles == false || nbEventSystemHandles <= 1)) {

            List<FmodEventAudioSource> tmpList = m_eventPoolManager.getAllActiveSources();
            foreach (FmodEventAudioSource src in tmpList) {
                if (src != null) {
                    src.Clean();
                }
            }
            if (m_musicSystem != null) {
                m_musicSystem.release();
                m_musicSystem = null;
            }
            if (_unloadAllFiles()) {
                ERRCHECK(m_eventSystem.unload());
            }
            if (m_eventSystem != null) {
                ERRCHECK(m_eventSystem.release());
                m_eventSystem = null;
            }

            if (m_system != null) {
                ERRCHECK(m_system.release());
                m_system = null;
            }

            m_eventSystemWasCleaned = true;
            m_eventSystemWasInit = false;
            WasCleaned = true;
            FmodEventSystem.m_FmodEventSystem = null;
        }
    }
 protected virtual void Dispose(bool disposing)
 {
     if (m_eventSystem != null) {
         if (m_nbHandles == 0) {
             Debug.LogWarning("FMOD_Unity: FmodEventSystemHandle: An event system is still referenced but there is no handle on it ! This should not happen !");
         } else {
             if (--m_nbHandles == 0 && Application.isEditor) {
                 m_eventSystem.clean();
                 m_eventSystem = null;
             }
         }
     }
 }