示例#1
0
    /// <summary>
    /// Initializes this instance.
    /// </summary>
    private void Initialize()
    {
        if (isInitialized && this.system != null && this.system.IsValid())
        {
            return;
        }
        isInitialized = true;

        Logger.LogMessage("Initializing FMOD");

        // Do these hacks before calling ANY fmod functions!
        if (!UnityUtil.ForceLoadLowLevelBinary())
        {
            Logger.LogError("Unable to load low level binary!");
        }

        Logger.LogMessage("Creating FMOD System");
        Logger.ErrorCheck(FMOD.Studio.System.Create(out system));

        if (system == null)
        {
            Logger.LogError("Unable to create FMOD System!");
            return;
        }

        Logger.LogMessage("System.initialize (" + system + ")");
        FMOD.Studio.InitFlags flags = FMOD.Studio.InitFlags.Normal;
#if FMOD_LIVEUPDATE
        flags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;
#endif

        FMOD.Result result = FMOD.Result.Ok;

        system.GetLowLevelSystem(out lowLevelSystem);
        UpdateDSPBufferSize();

        result = system.Initialize(1024, flags, FMOD.InitFlags.Normal, global::System.IntPtr.Zero);

        if (result == FMOD.Result.ErrorNetSocket)
        {
#if false && FMOD_LIVEUPDATE
            UnityUtil.LogWarning("LiveUpdate disabled: socket in already in use");
            flags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
            result = system.init(1024, flags, FMOD.INITFLAGS.NORMAL, (System.IntPtr)null);
#else
            Logger.LogError("Unable to initalize with LiveUpdate: socket is already in use");
#endif
        }
        else if (result == FMOD.Result.ErrorHeaderMismatch)
        {
            Logger.LogError("Version mismatch between C# script and FMOD binary, restart Unity and reimport the integration package to resolve this issue.");
        }
        else
        {
            Logger.ErrorCheck(result);
        }


        LoadPlugins();

        LoadAllBanks();
    }