Пример #1
0
 /// <summary>
 /// Updates this instance.
 /// </summary>
 private static void Update()
 {
     if (StudioSystem != null && StudioSystem.System != null && StudioSystem.System.IsValid())
     {
         Logger.ErrorCheck(StudioSystem.System.Update());
     }
 }
Пример #2
0
    /// <summary>
    /// Update3s the d attributes.
    /// </summary>
    private void Update3DAttributes()
    {
        //FMOD.Studio.System studioSystem = FMODStudioSystem.Instance.System;

        //if (studioSystem.System != null && studioSystem.System.IsValid()) {
        FMOD3DAttributes attributes = UnityUtil.To3DAttributes(gameObject, cachedRigidBody);

        Logger.ErrorCheck(studioSystem.System.SetListenerAttributes(attributes));
        //}
    }
    /// <summary>
    /// Starts the event.
    /// </summary>
    public void StartEvent()
    {
        if (evt == null || !evt.IsValid())
        {
            CacheEventInstance();
        }

        // Attempt to release as oneshot
        if (evt != null && evt.IsValid())
        {
            Update3DAttributes();
            Logger.ErrorCheck(evt.Start());
        }
        else
        {
            Logger.LogError("Event retrieval failed: " + path);
        }

        hasStarted = true;
    }
Пример #4
0
            // ----------------------------------------------------------------------------------------------------
            #endregion

            #region Loading Methods
            // ----------------------------------------------------------------------------------------------------
            /// <summary>
            /// Forces the load of the Low Level Binary.
            /// </summary>
            /// <returns></returns>
            public static bool ForceLoadLowLevelBinary()
            {
                Logger.Log("Loading Low Level Binary");

                // This is a hack that forces Android to load the .so libraries in the correct order
#if UNITY_ANDROID && !UNITY_EDITOR
                Logger.Log("Loading binaries: " + FMOD.Studio.STUDIO_VERSION.dll + " and " + FMOD.VERSION.dll);
                AndroidJavaClass jSystem = new AndroidJavaClass("java.lang.System");
                jSystem.CallStatic("loadLibrary", FMOD.VERSION.dll);
                jSystem.CallStatic("loadLibrary", FMOD.Studio.STUDIO_VERSION.dll);
#endif

                // Hack: force the low level binary to be loaded before accessing Studio API
#if !UNITY_IPHONE || UNITY_EDITOR
                int temp1, temp2;
                if (!Logger.ErrorCheck(FMOD.Memory.GetStats(out temp1, out temp2)))
                {
                    Logger.LogError("An error occured while loading Low Level Binary!");
                    return(false);
                }
#endif
                Logger.Log("Low Level Binary successfully loaded!");
                return(true);
            }
Пример #5
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();
    }