Example #1
0
        public static void About()
        {
            FMOD.System lowlevel;
            CheckResult(System.getLowLevelSystem(out lowlevel));

            uint version;

            CheckResult(lowlevel.getVersion(out version));

            EditorUtility.DisplayDialog("FMOD Studio Unity Integration", "Version: " + VerionNumberToString(version), "OK");
        }
Example #2
0
        static void CreateSystem()
        {
            UnityEngine.Debug.Log("FMOD Studio: Creating editor system instance");
            RuntimeUtils.EnforceLibraryOrder();

            FMOD.RESULT result = FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, "fmod_editor.log");
            if (result != FMOD.RESULT.OK)
            {
                UnityEngine.Debug.LogWarning("FMOD Studio: Cannot open fmod_editor.log. Logging will be disabled for importing and previewing");
            }

            CheckResult(FMOD.Studio.System.create(out system));

            FMOD.System lowlevel;
            CheckResult(system.getLowLevelSystem(out lowlevel));

            // Use play-in-editor speaker mode for event browser preview and metering
            lowlevel.setSoftwareFormat(0, (FMOD.SPEAKERMODE)Settings.Instance.GetSpeakerMode(FMODPlatform.Default), 0);

            CheckResult(system.initialize(256, FMOD.Studio.INITFLAGS.ALLOW_MISSING_PLUGINS | FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE, FMOD.INITFLAGS.NORMAL, IntPtr.Zero));

            FMOD.ChannelGroup master;
            CheckResult(lowlevel.getMasterChannelGroup(out master));
            FMOD.DSP masterHead;
            CheckResult(master.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, out masterHead));
            CheckResult(masterHead.setMeteringEnabled(false, true));
        }
Example #3
0
        public static void About()
        {
            FMOD.System lowlevel;
            CheckResult(System.getLowLevelSystem(out lowlevel));

            uint version;

            CheckResult(lowlevel.getVersion(out version));

            EditorUtility.DisplayDialog("FMOD Studio Unity Integration", "Version: " + VerionNumberToString(version) + "\n\nCopyright \u00A9 Firelight Technologies Pty, Ltd. 2014-2017 \n\nSee LICENSE.TXT for additional license information.", "OK");
        }
Example #4
0
        static void CreateSystem()
        {
            UnityEngine.Debug.Log("FMOD Studio: Creating editor system instance");
            RuntimeUtils.EnforceLibraryOrder();

            CheckResult(FMOD.Studio.System.create(out system));

            FMOD.System lowlevel;
            CheckResult(system.getLowLevelSystem(out lowlevel));

            // Use play-in-editor speaker mode for event browser preview and metering
            lowlevel.setSoftwareFormat(0, (FMOD.SPEAKERMODE)Settings.Instance.GetSpeakerMode(FMODPlatform.PlayInEditor), 0);

            CheckResult(system.initialize(256, FMOD.Studio.INITFLAGS.ALLOW_MISSING_PLUGINS | FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE, FMOD.INITFLAGS.NORMAL, IntPtr.Zero));

            FMOD.ChannelGroup master;
            CheckResult(lowlevel.getMasterChannelGroup(out master));
            FMOD.DSP masterHead;
            CheckResult(master.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, out masterHead));
            CheckResult(masterHead.setMeteringEnabled(false, true));
        }
Example #5
0
        FMOD.RESULT Initialize()
        {
            #if UNITY_EDITOR
                #if UNITY_2017_2_OR_NEWER
            AssemblyReloadEvents.beforeAssemblyReload += HandleBeforeAssemblyReload;
            EditorApplication.playModeStateChanged    += HandlePlayModeStateChange;
                #elif UNITY_2017_1_OR_NEWER
            EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged;
                #endif // UNITY_2017_2_OR_NEWER
            #endif     // UNITY_EDITOR

            FMOD.RESULT result       = FMOD.RESULT.OK;
            FMOD.RESULT initResult   = FMOD.RESULT.OK;
            Settings    fmodSettings = Settings.Instance;
            fmodPlatform = RuntimeUtils.GetCurrentPlatform();

            int sampleRate               = fmodSettings.GetSampleRate(fmodPlatform);
            int realChannels             = Math.Min(fmodSettings.GetRealChannels(fmodPlatform), 256); // Prior to 1.08.10 we didn't clamp this properly in the settings screen
            int virtualChannels          = fmodSettings.GetVirtualChannels(fmodPlatform);
            FMOD.SPEAKERMODE speakerMode = (FMOD.SPEAKERMODE)fmodSettings.GetSpeakerMode(fmodPlatform);
            FMOD.OUTPUTTYPE  outputType  = FMOD.OUTPUTTYPE.AUTODETECT;

            FMOD.ADVANCEDSETTINGS advancedSettings = new FMOD.ADVANCEDSETTINGS();
            advancedSettings.randomSeed = (uint)DateTime.Now.Ticks;
            #if UNITY_EDITOR || UNITY_STANDALONE
            advancedSettings.maxVorbisCodecs = realChannels;
            #elif UNITY_XBOXONE
            advancedSettings.maxXMACodecs = realChannels;
            #elif UNITY_PS4
            advancedSettings.maxAT9Codecs = realChannels;
            #else
            advancedSettings.maxFADPCMCodecs = realChannels;
            #endif

            SetThreadAffinity();

            #if UNITY_EDITOR || ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) && DEVELOPMENT_BUILD)
            result = FMOD.Debug.Initialize(fmodSettings.LoggingLevel, FMOD.DEBUG_MODE.CALLBACK, DEBUG_CALLBACK, null);
            CheckInitResult(result, "FMOD.Debug.Initialize");
            #endif

            FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;
            if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform))
            {
                studioInitFlags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;
                advancedSettings.profilePort = fmodSettings.LiveUpdatePort;
            }

retry:
            result = FMOD.Studio.System.create(out studioSystem);
            CheckInitResult(result, "FMOD.Studio.System.create");

            result = studioSystem.getLowLevelSystem(out lowlevelSystem);
            CheckInitResult(result, "FMOD.Studio.System.getLowLevelSystem");

            result = lowlevelSystem.setOutput(outputType);
            CheckInitResult(result, "FMOD.System.setOutput");

            result = lowlevelSystem.setSoftwareChannels(realChannels);
            CheckInitResult(result, "FMOD.System.setSoftwareChannels");

            result = lowlevelSystem.setSoftwareFormat(sampleRate, speakerMode, 0);
            CheckInitResult(result, "FMOD.System.setSoftwareFormat");

            result = lowlevelSystem.setAdvancedSettings(ref advancedSettings);
            CheckInitResult(result, "FMOD.System.setAdvancedSettings");

            result = studioSystem.initialize(virtualChannels, studioInitFlags, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
            if (result != FMOD.RESULT.OK && initResult == FMOD.RESULT.OK)
            {
                initResult = result; // Save this to throw at the end (we'll attempt NO SOUND to shield ourselves from unexpected device failures)
                outputType = FMOD.OUTPUTTYPE.NOSOUND;
                UnityEngine.Debug.LogErrorFormat("[FMOD] Studio::System::initialize returned {0}, defaulting to no-sound mode.", result.ToString());

                goto retry;
            }
            CheckInitResult(result, "Studio::System::initialize");

            // Test network functionality triggered during System::update
            if ((studioInitFlags & FMOD.Studio.INITFLAGS.LIVEUPDATE) != 0)
            {
                studioSystem.flushCommands(); // Any error will be returned through Studio.System.update

                result = studioSystem.update();
                if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
                {
                    studioInitFlags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
                    UnityEngine.Debug.LogWarning("[FMOD] Cannot open network port for Live Update (in-use), restarting with Live Update disabled.");

                    result = studioSystem.release();
                    CheckInitResult(result, "FMOD.Studio.System.Release");

                    goto retry;
                }
            }

            LoadPlugins(fmodSettings);
            LoadBanks(fmodSettings);

            return(initResult);
        }
        FMOD.RESULT Initialize()
        {
            FMOD.RESULT result       = FMOD.RESULT.OK;
            FMOD.RESULT initResult   = FMOD.RESULT.OK;
            Settings    fmodSettings = Settings.Instance;

            fmodPlatform = RuntimeUtils.GetCurrentPlatform();

            int sampleRate      = fmodSettings.GetSampleRate(fmodPlatform);
            int realChannels    = Math.Min(fmodSettings.GetRealChannels(fmodPlatform), 256); // Prior to 1.08.10 we didn't clamp this properly in the settings screen
            int virtualChannels = fmodSettings.GetVirtualChannels(fmodPlatform);

            FMOD.SPEAKERMODE speakerMode = (FMOD.SPEAKERMODE)fmodSettings.GetSpeakerMode(fmodPlatform);
            FMOD.OUTPUTTYPE  outputType  = FMOD.OUTPUTTYPE.AUTODETECT;

            FMOD.ADVANCEDSETTINGS advancedSettings = new FMOD.ADVANCEDSETTINGS();
            advancedSettings.randomSeed = (uint)DateTime.Now.Ticks;
            #if UNITY_EDITOR || UNITY_STANDALONE
            advancedSettings.maxVorbisCodecs = realChannels;
            #elif UNITY_XBOXONE
            advancedSettings.maxXMACodecs = realChannels;
            #elif UNITY_PS4
            advancedSettings.maxAT9Codecs = realChannels;
            #else
            advancedSettings.maxFADPCMCodecs = realChannels;
            #endif

            #if UNITY_EDITOR || ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) && DEVELOPMENT_BUILD)
            result = FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, RuntimeUtils.LogFileName);
            if (result == FMOD.RESULT.ERR_FILE_NOTFOUND)
            {
                UnityEngine.Debug.LogWarningFormat("FMOD Studio: Cannot open FMOD debug log file '{0}', logs will be missing for this session.", System.IO.Path.Combine(Application.dataPath, RuntimeUtils.LogFileName));
            }
            else
            {
                CheckInitResult(result, "FMOD.Debug.Initialize");
            }
            #endif

            FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;
            if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform))
            {
                studioInitFlags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;

                #if UNITY_5_0 || UNITY_5_1 // These versions of Unity shipped with FMOD4 profiling enabled consuming our port number.
                UnityEngine.Debug.LogWarning("FMOD Studio: Live Update port in-use by Unity, switching to port 9265");
                advancedSettings.profilePort = 9265;
                #endif
            }

retry:
            result = FMOD.Studio.System.create(out studioSystem);
            CheckInitResult(result, "FMOD.Studio.System.create");

            result = studioSystem.getLowLevelSystem(out lowlevelSystem);
            CheckInitResult(result, "FMOD.Studio.System.getLowLevelSystem");

            result = lowlevelSystem.setOutput(outputType);
            CheckInitResult(result, "FMOD.System.setOutput");

            result = lowlevelSystem.setSoftwareChannels(realChannels);
            CheckInitResult(result, "FMOD.System.setSoftwareChannels");

            result = lowlevelSystem.setSoftwareFormat(sampleRate, speakerMode, 0);
            CheckInitResult(result, "FMOD.System.setSoftwareFormat");

            result = lowlevelSystem.setAdvancedSettings(ref advancedSettings);
            CheckInitResult(result, "FMOD.System.setAdvancedSettings");

            result = studioSystem.initialize(virtualChannels, studioInitFlags, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
            if (result != FMOD.RESULT.OK && initResult == FMOD.RESULT.OK)
            {
                initResult = result; // Save this to throw at the end (we'll attempt NO SOUND to shield ourselves from unexpected device failures)
                outputType = FMOD.OUTPUTTYPE.NOSOUND;
                UnityEngine.Debug.LogErrorFormat("FMOD Studio: Studio::System::initialize returned {0}, defaulting to no-sound mode.", result.ToString());

                goto retry;
            }
            CheckInitResult(result, "Studio::System::initialize");

            // Test network functionality triggered during System::update
            if ((studioInitFlags & FMOD.Studio.INITFLAGS.LIVEUPDATE) != 0)
            {
                studioSystem.flushCommands(); // Any error will be returned through Studio.System.update

                result = studioSystem.update();
                if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
                {
                    studioInitFlags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
                    UnityEngine.Debug.LogWarning("FMOD Studio: Cannot open network port for Live Update (in-use), restarting with Live Update disabled.");

                    result = studioSystem.release();
                    CheckInitResult(result, "FMOD.Studio.System.Release");

                    goto retry;
                }
            }

            LoadPlugins(fmodSettings);
            LoadBanks(fmodSettings);

            return(initResult);
        }
        void Initialiase(bool forceNoNetwork)
        {
            UnityEngine.Debug.Log("FMOD Studio: Creating runtime system instance");

            FMOD.RESULT result;
            result = FMOD.Studio.System.create(out studioSystem);
            CheckInitResult(result, "Creating System Object");
            studioSystem.getLowLevelSystem(out lowlevelSystem);

            Settings fmodSettings = Settings.Instance;

            fmodPlatform = RuntimeUtils.GetCurrentPlatform();

            #if UNITY_EDITOR || ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) && DEVELOPMENT_BUILD)
            result = FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, RuntimeUtils.LogFileName);
            if (result == FMOD.RESULT.ERR_FILE_NOTFOUND)
            {
#if UNITY_5_X
                Debug.LogWarningFormat("FMOD Studio: Cannot open FMOD debug log file '{0}', logs will be missing for this session.", System.IO.Path.Combine(Application.dataPath, RuntimeUtils.LogFileName));
#else
                Debug.LogWarning(string.Format("FMOD Studio: Cannot open FMOD debug log file '{0}', logs will be missing for this session.", System.IO.Path.Combine(Application.dataPath, RuntimeUtils.LogFileName)));
#endif
            }
            else
            {
                CheckInitResult(result, "Applying debug settings");
            }
            #endif

            int realChannels = fmodSettings.GetRealChannels(fmodPlatform);

            realChannels = Math.Min(realChannels, 256); // Prior to 1.08.10 we didn't clamp this properly in the settings screen

            result = lowlevelSystem.setSoftwareChannels(realChannels);
            CheckInitResult(result, "Set software channels");
            result = lowlevelSystem.setSoftwareFormat(
                fmodSettings.GetSampleRate(fmodPlatform),
                (FMOD.SPEAKERMODE)fmodSettings.GetSpeakerMode(fmodPlatform),
                0 // raw not supported
                );
            CheckInitResult(result, "Set software format");

            // Setup up the platforms recommended codec to match the real channel count
            FMOD.ADVANCEDSETTINGS advancedsettings = new FMOD.ADVANCEDSETTINGS();
            #if UNITY_EDITOR || UNITY_STANDALONE
            advancedsettings.maxVorbisCodecs = realChannels;
            #elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8_1 || UNITY_PSP2 || UNITY_WII
            advancedsettings.maxFADPCMCodecs = realChannels;
            #elif UNITY_XBOXONE
            advancedsettings.maxXMACodecs = realChannels;
            #elif UNITY_PS4
            advancedsettings.maxAT9Codecs = realChannels;
            #endif

            #if UNITY_5_0 || UNITY_5_1
            if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform) && !forceNoNetwork)
            {
                UnityEngine.Debug.LogWarning("FMOD Studio: Detected Unity 5, running on port 9265");
                advancedsettings.profilePort = 9265;
            }
            #endif

            advancedsettings.randomSeed = (uint)DateTime.Now.Ticks;
            result = lowlevelSystem.setAdvancedSettings(ref advancedsettings);
            CheckInitResult(result, "Set advanced settings");

            FMOD.INITFLAGS        lowlevelInitFlags = FMOD.INITFLAGS.NORMAL;
            FMOD.Studio.INITFLAGS studioInitFlags   = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;

            if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform) && !forceNoNetwork)
            {
                studioInitFlags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;
            }

            FMOD.RESULT initResult = studioSystem.initialize(
                fmodSettings.GetVirtualChannels(fmodPlatform),
                studioInitFlags,
                lowlevelInitFlags,
                IntPtr.Zero
                );

            CheckInitResult(initResult, "Calling initialize");

            // Dummy flush and update to get network state
            studioSystem.flushCommands();
            FMOD.RESULT updateResult = studioSystem.update();

            // Restart without liveupdate if there was a socket error
            if (updateResult == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
            {
                studioSystem.release();
                UnityEngine.Debug.LogWarning("FMOD Studio: Cannot open network port for Live Update, restarting with Live Update disabled. Check for other applications that are running FMOD Studio");
                Initialiase(true);
            }
            else
            {
                // Load plugins (before banks)
                        #if (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR
                FmodUnityNativePluginInit(lowlevelSystem.getRaw());
                                #else
                foreach (var pluginName in fmodSettings.Plugins)
                {
                    string pluginPath = RuntimeUtils.GetPluginPath(pluginName);
                    uint   handle;
                    result = lowlevelSystem.loadPlugin(pluginPath, out handle);
                    #if UNITY_64 || UNITY_EDITOR_64
                    // Add a "64" suffix and try again
                    if (result == FMOD.RESULT.ERR_FILE_BAD || result == FMOD.RESULT.ERR_FILE_NOTFOUND)
                    {
                        string pluginPath64 = RuntimeUtils.GetPluginPath(pluginName + "64");
                        result = lowlevelSystem.loadPlugin(pluginPath64, out handle);
                    }
                    #endif
                    CheckInitResult(result, String.Format("Loading plugin '{0}' from '{1}'", pluginName, pluginPath));
                    loadedPlugins.Add(pluginName, handle);
                }
                #endif

                if (fmodSettings.ImportType == ImportType.StreamingAssets)
                {
                    // Always load strings bank
                    try
                    {
                        LoadBank(fmodSettings.MasterBank + ".strings", fmodSettings.AutomaticSampleLoading);
                    }
                    catch (BankLoadException e)
                    {
                        UnityEngine.Debug.LogException(e);
                    }

                    if (fmodSettings.AutomaticEventLoading)
                    {
                        try
                        {
                            LoadBank(fmodSettings.MasterBank, fmodSettings.AutomaticSampleLoading);
                        }
                        catch (BankLoadException e)
                        {
                            UnityEngine.Debug.LogException(e);
                        }

                        foreach (var bank in fmodSettings.Banks)
                        {
                            try
                            {
                                LoadBank(bank, fmodSettings.AutomaticSampleLoading);
                            }
                            catch (BankLoadException e)
                            {
                                UnityEngine.Debug.LogException(e);
                            }
                        }

                        WaitForAllLoads();
                    }
                }
            };

            FMOD.ChannelGroup master;
            lowlevelSystem.getMasterChannelGroup(out master);
            master.getDSP(0, out mixerHead);
            mixerHead.setMeteringEnabled(false, true);
        }
Example #8
0
        public void LoadWorldFromFile(string filename)
        {
            XmlDocument map = new XmlDocument();

            map.Load(filename);
            XmlElement root = map.DocumentElement;

            foreach (XmlNode node in root)
            {
                if (node.Attributes.Count > 0)
                {
                    if (node.Name == "world")
                    {
                        if (node.ChildNodes.Count > 0)
                        {
                            foreach (XmlNode actor in node)
                            {
                                if (actor.Name == "actor")
                                {
                                    if (actor.Attributes.Count > 0)
                                    {
                                        if (actor.Attributes.GetNamedItem("x") != null && actor.Attributes.GetNamedItem("y") != null && actor.Attributes.GetNamedItem("height") != null && actor.Attributes.GetNamedItem("width") != null && actor.Attributes.GetNamedItem("layer") != null && actor.Attributes.GetNamedItem("drawassprite") != null && actor.Attributes.GetNamedItem("hascollision") != null && actor.Attributes.GetNamedItem("imagefile") != null)
                                        {
                                            Image      g         = Image.FromFile(actor.Attributes.GetNamedItem("imagefile").Value);
                                            RectangleF collision = new RectangleF();
                                            collision.X      = Convert.ToSingle(actor.Attributes.GetNamedItem("x").Value);
                                            collision.Y      = Convert.ToSingle(actor.Attributes.GetNamedItem("y").Value);
                                            collision.Width  = Convert.ToSingle(actor.Attributes.GetNamedItem("width").Value);
                                            collision.Height = Convert.ToSingle(actor.Attributes.GetNamedItem("height").Value);
                                            if (actor.Attributes.GetNamedItem("height").Value == "-1")
                                            {
                                                collision.Width = g.Width;
                                            }
                                            if (actor.Attributes.GetNamedItem("width").Value == "-1")
                                            {
                                                collision.Height = g.Height;
                                            }
                                            int  layer        = Convert.ToInt32(actor.Attributes.GetNamedItem("layer").Value);
                                            bool drawassprite = Convert.ToBoolean(actor.Attributes.GetNamedItem("drawassprite").Value);
                                            bool hascollision = Convert.ToBoolean(actor.Attributes.GetNamedItem("hascollision").Value);

                                            if (actor.Attributes.GetNamedItem("type") != null)
                                            {
                                                if (actor.Attributes.GetNamedItem("type").Value == "solid")
                                                {
                                                    world.World_Actors.Add(new Actor(g, layer, hascollision, collision, drawassprite));
                                                }
                                                if (actor.Attributes.GetNamedItem("type").Value == "trigger")
                                                {
                                                    if (actor.Attributes.GetNamedItem("trigger_type") != null && actor.Attributes.GetNamedItem("enter_dir") != null && actor.Attributes.GetNamedItem("trigger_use_type") != null)
                                                    {
                                                        //MoveDirection md = (MoveDirection)Convert.ToInt32(actor.Attributes.GetNamedItem("enter_dir").Value);
                                                        //TriggerType tt = (TriggerType)Convert.ToInt32(actor.Attributes.GetNamedItem("trigger_type").Value);

                                                        MoveDirection md = MoveDirection.NONE;
                                                        Enum.TryParse <MoveDirection>(actor.Attributes.GetNamedItem("enter_dir").Value, out md);
                                                        TriggerType tt = TriggerType.Once;
                                                        Enum.TryParse <TriggerType>(actor.Attributes.GetNamedItem("trigger_type").Value, out tt);

                                                        if (actor.Attributes.GetNamedItem("trigger_type").Value == "change_layer")
                                                        {
                                                            int tlayer = Convert.ToInt32(actor.Attributes.GetNamedItem("target_layer").Value);
                                                            world.World_Actors.Add(new Trigger_Change_Layer(tt, md, tlayer, g, layer, hascollision, collision, drawassprite));
                                                        }
                                                    }
                                                }
                                                if (actor.Attributes.GetNamedItem("type").Value == "func")
                                                {
                                                    if (actor.Attributes.GetNamedItem("func_type") != null)
                                                    {
                                                        if (actor.Attributes.GetNamedItem("func_type").Value == "view_layer")
                                                        {
                                                            if (actor.Attributes.GetNamedItem("t_x") != null && actor.Attributes.GetNamedItem("t_y") != null && actor.Attributes.GetNamedItem("t_height") != null && actor.Attributes.GetNamedItem("t_width") != null && actor.Attributes.GetNamedItem("target_layer") != null)
                                                            {
                                                                float tx      = Convert.ToSingle(actor.Attributes.GetNamedItem("t_x").Value);
                                                                float ty      = Convert.ToSingle(actor.Attributes.GetNamedItem("t_y").Value);
                                                                float twidth  = Convert.ToSingle(actor.Attributes.GetNamedItem("t_width").Value);
                                                                float theight = Convert.ToSingle(actor.Attributes.GetNamedItem("t_height").Value);
                                                                int   tlayer  = Convert.ToInt32(actor.Attributes.GetNamedItem("target_layer").Value);
                                                                world.World_Actors.Add(new Func_View_Layer(tlayer, new RectangleF(tx, ty, twidth, theight), g, layer, hascollision, collision, drawassprite));
                                                            }
                                                        }
                                                    }
                                                }
                                                if (actor.Attributes.GetNamedItem("type").Value == "reverb")
                                                {
                                                    if (actor.Attributes.GetNamedItem("z") != null && actor.Attributes.GetNamedItem("max") != null && actor.Attributes.GetNamedItem("min") != null && actor.Attributes.GetNamedItem("reverb_preset_name") != null)
                                                    {
                                                        Reverb_Props_Presets rp = Reverb_Props_Presets.OFF;
                                                        float z   = Convert.ToSingle(actor.Attributes.GetNamedItem("z").Value);
                                                        float min = Convert.ToSingle(actor.Attributes.GetNamedItem("min").Value);
                                                        float max = Convert.ToSingle(actor.Attributes.GetNamedItem("max").Value);

                                                        Enum.TryParse <Reverb_Props_Presets>(actor.Attributes.GetNamedItem("reverb_preset_name").Value, out rp);
                                                        REVERB_PROPERTIES rev = Reverb_Area.LoadPreset(rp);
                                                        FMOD.System       system;
                                                        Sound_System.getLowLevelSystem(out system);

                                                        world.World_Actors.Add(new Reverb_Area(system, new Reverb_Attributes(Vector.ToVECTOR(0, 0, 0), 0, 1000), ref rev, g, layer, hascollision, collision, drawassprite));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (node.Name == "entity")
                    {
                        if (node.ChildNodes.Count > 0)
                        {
                            foreach (XmlNode ent in node)
                            {
                                if (ent.Name == "ent")
                                {
                                    if (ent.Attributes.Count > 0)
                                    {
                                        if (ent.Attributes.GetNamedItem("name") != null)
                                        {
                                            if (ent.Attributes.GetNamedItem("name").Value == "player_start")
                                            {
                                                if (ent.Attributes.GetNamedItem("x") != null && ent.Attributes.GetNamedItem("y") != null)
                                                {
                                                    player.SetX(Convert.ToSingle(ent.Attributes.GetNamedItem("x").Value));
                                                    player.SetX(Convert.ToSingle(ent.Attributes.GetNamedItem("y").Value));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        void Initialiase(bool forceNoNetwork)
        {
            FMOD.RESULT result;
            result = FMOD.Studio.System.create(out studioSystem);
            CheckInitResult(result, "Creating System Object");
            studioSystem.getLowLevelSystem(out lowlevelSystem);

            Settings     fmodSettings = Settings.Instance;
            FMODPlatform fmodPlatform = RuntimeUtils.GetCurrentPlatform();


            #if UNITY_EDITOR || ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) && DEVELOPMENT_BUILD)
            result = FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, RuntimeUtils.LogFileName);
            CheckInitResult(result, "Applying debug settings");
            #endif

            int realChannels = fmodSettings.GetRealChannels(fmodPlatform);
            result = lowlevelSystem.setSoftwareChannels(realChannels);
            CheckInitResult(result, "Set software channels");
            result = lowlevelSystem.setSoftwareFormat(
                fmodSettings.GetSampleRate(fmodPlatform),
                (FMOD.SPEAKERMODE)fmodSettings.GetSpeakerMode(fmodPlatform),
                0 // raw not supported
                );
            CheckInitResult(result, "Set software format");

            // Setup up the platforms recommended codec to match the real channel count
            FMOD.ADVANCEDSETTINGS advancedsettings = new FMOD.ADVANCEDSETTINGS();
            #if UNITY_EDITOR || UNITY_STANDALONE
            advancedsettings.maxVorbisCodecs = realChannels;
            #elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8_1 || UNITY_PSP2 || UNITY_WII
            advancedsettings.maxFADPCMCodecs = realChannels;
            #elif UNITY_XBOXONE
            advancedsettings.maxXMACodecs = realChannels;
            #elif UNITY_PS4
            advancedsettings.maxAT9Codecs = realChannels;
            #endif

            #if UNITY_5_0 || UNITY_5_1
            if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform) && !forceNoNetwork)
            {
                UnityEngine.Debug.LogWarning("FMOD Studio: Detected Unity 5, running on port 9265");
                advancedsettings.profilePort = 9265;
            }
            #endif

            advancedsettings.randomSeed = (uint)DateTime.Now.Ticks;
            result = lowlevelSystem.setAdvancedSettings(ref advancedsettings);
            CheckInitResult(result, "Set advanced settings");

            FMOD.INITFLAGS        lowlevelInitFlags = FMOD.INITFLAGS.NORMAL;
            FMOD.Studio.INITFLAGS studioInitFlags   = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;

            if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform) && !forceNoNetwork)
            {
                studioInitFlags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;
            }

            FMOD.RESULT initResult = studioSystem.initialize(
                fmodSettings.GetVirtualChannels(fmodPlatform),
                studioInitFlags,
                lowlevelInitFlags,
                IntPtr.Zero
                );

            CheckInitResult(initResult, "Calling initialize");

            // Dummy flush and update to get network state
            studioSystem.flushCommands();
            FMOD.RESULT updateResult = studioSystem.update();

            // Restart without liveupdate if there was a socket error
            if (updateResult == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
            {
                studioSystem.release();
                UnityEngine.Debug.LogWarning("FMOD Studio: Cannot network port for Live Update, restarting with Live Update disabled. Check for other applications that are running FMOD Studio");
                Initialiase(true);
            }
            else
            {
                try
                {
                    // Always load strings bank
                    LoadBank(fmodSettings.MasterBank + ".strings", fmodSettings.AutomaticSampleLoading);

                    if (fmodSettings.AutomaticEventLoading)
                    {
                        LoadBank(fmodSettings.MasterBank, fmodSettings.AutomaticSampleLoading);

                        foreach (var bank in fmodSettings.Banks)
                        {
                            LoadBank(bank, fmodSettings.AutomaticSampleLoading);
                        }
                    }
                }
                catch (BankLoadException e)
                {
                    throw new SystemNotInitializedException(e.Result, String.Format("Loading Bank '{0}'", e.Path));
                }

                foreach (var pluginName in fmodSettings.Plugins)
                {
                    string pluginPath = RuntimeUtils.GetPluginPath(pluginName);
                    uint   handle;
                    result = lowlevelSystem.loadPlugin(pluginPath, out handle);
                    CheckInitResult(result, String.Format("Loading plugin '{0}' from '{1}'", pluginName, pluginPath));
                    loadedPlugins.Add(pluginName, handle);
                }
            };
        }