Inheritance: MonoBehaviour
Beispiel #1
0
 private void Start()
 {
     FMOD_StudioSystem.PreloadEvent(this.rockOnTree);
     FMOD_StudioSystem.PreloadEvent(this.rockBush);
     FMOD_StudioSystem.PreloadEvent(this.rockWater);
     FMOD_StudioSystem.PreloadEvent(this.rockOnGround);
 }
Beispiel #2
0
    public EventInstance GetEvent(string path)
    {
        EventInstance eventInstance = null;

        if (string.IsNullOrEmpty(path))
        {
            UnityUtil.LogError("Empty event path!");
            return(null);
        }
        if (this.eventDescriptions.ContainsKey(path))
        {
            FMOD_StudioSystem.ERRCHECK(this.eventDescriptions[path].createInstance(out eventInstance));
        }
        else
        {
            EventDescription eventDescription = null;
            FMOD_StudioSystem.ERRCHECK(this.system.getEvent(path, out eventDescription));
            if (eventDescription != null && eventDescription.isValid())
            {
                this.eventDescriptions.Add(path, eventDescription);
                FMOD_StudioSystem.ERRCHECK(eventDescription.createInstance(out eventInstance));
            }
        }
        if (eventInstance == null)
        {
            UnityUtil.Log("GetEvent FAILED: \"" + path + "\"");
        }
        return(eventInstance);
    }
Beispiel #3
0
 private void Update()
 {
     if (this.isInitialized)
     {
         FMOD_StudioSystem.ERRCHECK(this.system.update());
     }
 }
Beispiel #4
0
 private void Preload()
 {
     string[] array = this.preloadEvents;
     for (int i = 0; i < array.Length; i++)
     {
         string text = array[i];
         UnityUtil.Log(string.Format("Preloading {0}...", text));
         bool             flag = false;
         EventDescription eventDescription;
         if (UnityUtil.ERRCHECK(FMOD_StudioSystem.instance.System.getEvent(text, out eventDescription)))
         {
             flag = UnityUtil.ERRCHECK(eventDescription.loadSampleData());
         }
         if (flag)
         {
             UnityUtil.Log(string.Format("Preloading {0} succeeded.", text));
         }
         else
         {
             UnityUtil.LogWarning(string.Format("Preloading {0} failed!", text));
         }
     }
     foreach (KeyValuePair <string, int> current in FMOD_Listener.sPreloadRequests)
     {
         if (current.Value > 0)
         {
             FMOD_StudioSystem.PreloadEvent(current.Key, current.Value);
         }
     }
     FMOD_Listener.sPreloadRequests.Clear();
     FMOD_Listener.sPreloadComplete = true;
 }
Beispiel #5
0
 public override void TryPreload()
 {
     if (!this.preloadComplete)
     {
         this.preloadComplete = FMOD_StudioSystem.PreloadEvent(this.OpenEvent);
     }
 }
Beispiel #6
0
 private void Update()
 {
     if (FMOD_StudioSystem.isInitialized && this.system != null)
     {
         FMOD_StudioSystem.ERRCHECK(this.system.update());
     }
 }
Beispiel #7
0
 private void OnDisable()
 {
     if (this.isInitialized)
     {
         UnityUtil.Log("__ SHUT DOWN FMOD SYSTEM __");
         FMOD_StudioSystem.ERRCHECK(this.system.release());
     }
 }
Beispiel #8
0
 private void Start()
 {
     this.doStart();
     if (!CoopPeerStarter.DedicatedHost)
     {
         FMOD_StudioSystem.PreloadEvent(this.walkFootstepEvent);
         FMOD_StudioSystem.PreloadEvent(this.runFootstepEvent);
     }
 }
Beispiel #9
0
 private void Start()
 {
     if (!CoopPeerStarter.DedicatedHost)
     {
         FMOD_StudioSystem.PreloadEvent(this.rockOnTree);
         FMOD_StudioSystem.PreloadEvent(this.rockBush);
         FMOD_StudioSystem.PreloadEvent(this.rockWater);
         FMOD_StudioSystem.PreloadEvent(this.rockOnGround);
     }
 }
Beispiel #10
0
    public Bus GetBus(string strBus)
    {
        Bus bus = null;

        FMOD_StudioSystem.ERRCHECK(this.system.getBus(strBus, out bus));
        if (bus == null)
        {
            UnityUtil.Log("GetBus FAILED!!!");
        }
        return(bus);
    }
Beispiel #11
0
    public VCA GetVCA(string path)
    {
        VCA vCA = null;

        FMOD_StudioSystem.ERRCHECK(this.system.getVCA(path, out vCA));
        if (vCA == null)
        {
            UnityUtil.Log("GetVCA FAILED!!!");
        }
        return(vCA);
    }
Beispiel #12
0
 public void OutputEventsInfo()
 {
     UnityEngine.Debug.Log("<color=yellow>------------------------- OutputEventsInfo -------------------------</color>");
     UnityEngine.Debug.Log("events cnt: " + this.eventDescriptions.Count);
     foreach (KeyValuePair <string, EventDescription> current in this.eventDescriptions)
     {
         bool flag;
         FMOD_StudioSystem.ERRCHECK(current.Value.is3D(out flag));
         bool flag2;
         FMOD_StudioSystem.ERRCHECK(current.Value.isStream(out flag2));
         EventInstance[] array;
         FMOD_StudioSystem.ERRCHECK(current.Value.getInstanceList(out array));
         string text = "instance info:";
         if (array != null && array.Length > 0)
         {
             for (int i = 0; i < array.Length; i++)
             {
                 EventDescription eventDescription;
                 array[i].getDescription(out eventDescription);
                 string str;
                 eventDescription.getPath(out str);
                 text = text + str + " ";
             }
             UnityEngine.Debug.Log(string.Concat(new object[]
             {
                 "key: ",
                 current.Key,
                 " 3d:",
                 flag,
                 " isstream:",
                 flag2,
                 " instances cnt:",
                 array.Length,
                 " detail: ",
                 text
             }));
         }
         else
         {
             UnityEngine.Debug.Log(string.Concat(new object[]
             {
                 "key: ",
                 current.Key,
                 " 3d:",
                 flag,
                 " isstream:",
                 flag2,
                 " instances cnt:0"
             }));
         }
     }
 }
Beispiel #13
0
    void OnDisable()
    {
        if (isInitialized)
        {
            FMOD.Studio.UnityUtil.Log("__ SHUT DOWN FMOD SYSTEM __");
            ERRCHECK(system.release());

            if (this == sInstance)
            {
                sInstance = null;
            }
        }
    }
Beispiel #14
0
 private void Start()
 {
     string[] array = this.AllEventPaths();
     for (int i = 0; i < array.Length; i++)
     {
         string path = array[i];
         FMOD_StudioSystem.PreloadEvent(path);
     }
     if (this.Remote)
     {
         return;
     }
     this.prevPosition = base.GetComponent <Rigidbody>().position;
 }
Beispiel #15
0
 private void OnDisable()
 {
     if (FMOD_StudioSystem.isInitialized)
     {
         UnityUtil.Log("__ SHUT DOWN FMOD SYSTEM __");
         if (this.system != null)
         {
             this.system.release();
         }
         if (this == FMOD_StudioSystem.sInstance)
         {
             FMOD_StudioSystem.sInstance = null;
         }
     }
 }
Beispiel #16
0
    public void PlayOneShot(string path, Vector3 position, float volume)
    {
        EventInstance @event = this.GetEvent(path);

        if (@event == null)
        {
            UnityUtil.LogWarning("PlayOneShot couldn't find event: \"" + path + "\"");
            return;
        }
        FMOD.Studio.ATTRIBUTES_3D attributes = position.to3DAttributes();
        FMOD_StudioSystem.ERRCHECK(@event.set3DAttributes(attributes));
        FMOD_StudioSystem.ERRCHECK(@event.setVolume(volume));
        FMOD_StudioSystem.ERRCHECK(@event.start());
        FMOD_StudioSystem.ERRCHECK(@event.release());
    }
Beispiel #17
0
    private EventInstance PlayOneShot(string path, Vector3 position, float volume, FMOD_StudioSystem.ProcessEventInstanceDelegate eventSetup = null)
    {
        if (this.ShouldBeCulled(path, position))
        {
            return(null);
        }
        EventInstance @event = this.GetEvent(path);

        FMOD.Studio.ATTRIBUTES_3D attributes = position.to3DAttributes();
        FMOD_StudioSystem.ERRCHECK(@event.set3DAttributes(attributes));
        if (eventSetup == null || eventSetup(@event))
        {
            FMOD_StudioSystem.ERRCHECK(@event.start());
        }
        FMOD_StudioSystem.ERRCHECK(@event.release());
        return(@event);
    }
Beispiel #18
0
 private void OnApplicationPause(bool pauseStatus)
 {
     if (this.system != null)
     {
         FMOD.System system;
         FMOD_StudioSystem.ERRCHECK(this.system.getLowLevelSystem(out system));
         UnityUtil.Log("Pause state changed to: " + pauseStatus);
         if (pauseStatus)
         {
             FMOD_StudioSystem.ERRCHECK(system.mixerSuspend());
         }
         else
         {
             FMOD_StudioSystem.ERRCHECK(system.mixerResume());
         }
     }
 }
Beispiel #19
0
 public static void UnPreload(string path)
 {
     if (FMOD_Listener.sPreloadComplete)
     {
         FMOD_StudioSystem.UnPreloadEvent(path);
     }
     else if (FMOD_Listener.sPreloadRequests.ContainsKey(path))
     {
         Dictionary <string, int> dictionary;
         Dictionary <string, int> expr_2A = dictionary = FMOD_Listener.sPreloadRequests;
         int num = dictionary[path];
         expr_2A[path] = num - 1;
     }
     else
     {
         FMOD_Listener.sPreloadRequests[path] = -1;
     }
 }
Beispiel #20
0
    private void Init()
    {
        UnityUtil.Log("FMOD_StudioSystem: Initialize");
        if (FMOD_StudioSystem.isInitialized)
        {
            return;
        }
        UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
        UnityUtil.Log("FMOD_StudioSystem: System_Create");
        FMOD_StudioSystem.ERRCHECK(FMOD.Studio.System.create(out this.system));
        FMOD.Studio.INITFLAGS iNITFLAGS = FMOD.Studio.INITFLAGS.NORMAL;
        FMOD.System           system;
        FMOD_StudioSystem.ERRCHECK(this.system.getLowLevelSystem(out system));
        FMOD.ADVANCEDSETTINGS aDVANCEDSETTINGS = default(FMOD.ADVANCEDSETTINGS);
        aDVANCEDSETTINGS.randomSeed = (uint)DateTime.Now.Ticks;
        FMOD_StudioSystem.ERRCHECK(system.setAdvancedSettings(ref aDVANCEDSETTINGS));
        UnityUtil.Log("FMOD_StudioSystem: system.init");
        RESULT rESULT = this.system.initialize(1024, iNITFLAGS, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);

        if (rESULT == RESULT.ERR_HEADER_MISMATCH)
        {
            UnityUtil.LogError("Version mismatch between C# script and FMOD binary, restart Unity and reimport the integration package to resolve this issue.");
        }
        else
        {
            FMOD_StudioSystem.ERRCHECK(rESULT);
        }
        FMOD_StudioSystem.ERRCHECK(this.system.flushCommands());
        rESULT = this.system.update();
        if (rESULT == RESULT.ERR_NET_SOCKET_ERROR)
        {
            UnityUtil.LogWarning("LiveUpdate disabled: socket in already in use");
            iNITFLAGS &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
            FMOD_StudioSystem.ERRCHECK(this.system.release());
            FMOD_StudioSystem.ERRCHECK(FMOD.Studio.System.create(out this.system));
            FMOD_StudioSystem.ERRCHECK(this.system.getLowLevelSystem(out system));
            aDVANCEDSETTINGS            = default(FMOD.ADVANCEDSETTINGS);
            aDVANCEDSETTINGS.randomSeed = (uint)DateTime.Now.Ticks;
            FMOD_StudioSystem.ERRCHECK(system.setAdvancedSettings(ref aDVANCEDSETTINGS));
            rESULT = this.system.initialize(1024, iNITFLAGS, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
            FMOD_StudioSystem.ERRCHECK(rESULT);
        }
        FMOD_StudioSystem.isInitialized = true;
    }
Beispiel #21
0
    public EventInstance GetEvent(string path)
    {
        EventInstance eventInstance = null;

        if (string.IsNullOrEmpty(path))
        {
            UnityUtil.LogError("Empty event path!");
            return(null);
        }
        if (this.eventDescriptions.ContainsKey(path) && this.eventDescriptions[path].isValid())
        {
            FMOD_StudioSystem.ERRCHECK(this.eventDescriptions[path].createInstance(out eventInstance));
        }
        else
        {
            Guid guid = default(Guid);
            if (path.StartsWith("{"))
            {
                FMOD_StudioSystem.ERRCHECK(Util.ParseID(path, out guid));
            }
            else if (path.StartsWith("event:") || path.StartsWith("snapshot:"))
            {
                FMOD_StudioSystem.ERRCHECK(this.system.lookupID(path, out guid));
            }
            else
            {
                UnityUtil.LogError("Expected event path to start with 'event:/' or 'snapshot:/'");
            }
            EventDescription eventDescription = null;
            FMOD_StudioSystem.ERRCHECK(this.system.getEventByID(guid, out eventDescription));
            if (eventDescription != null && eventDescription.isValid())
            {
                this.eventDescriptions[path] = eventDescription;
                FMOD_StudioSystem.ERRCHECK(eventDescription.createInstance(out eventInstance));
            }
        }
        if (eventInstance == null)
        {
            UnityUtil.Log("GetEvent FAILED: \"" + path + "\"");
        }
        return(eventInstance);
    }
Beispiel #22
0
 private void Start()
 {
     if (!CoopPeerStarter.DedicatedHost)
     {
         foreach (string path in this.AllEventPaths())
         {
             FMOD_StudioSystem.PreloadEvent(path);
         }
         if (!this.Remote)
         {
             this.ZiplineLoopInstance = FMOD_StudioSystem.instance.GetEvent(this.ZiplineLoopEvent);
             if (this.ZiplineLoopInstance != null)
             {
                 this.ZiplineLoopInstance.getParameter("speed", out this.ZiplineLoopSpeedParameter);
             }
             this.GliderLoopInstance = FMOD_StudioSystem.instance.GetEvent(this.GliderLoopEvent);
             if (this.GliderLoopInstance != null)
             {
                 this.GliderLoopInstance.getParameter("speed", out this.GliderLoopSpeedParameter);
             }
             this.CraneLoopInstance           = FMOD_StudioSystem.instance.GetEvent(this.CraneLoopEvent);
             this.TurtleShellSledLoopInstance = FMOD_StudioSystem.instance.GetEvent(this.TurtleShellSledLoopEvent);
             if (this.TurtleShellSledLoopInstance != null)
             {
                 this.TurtleShellSledLoopInstance.getParameter("speed", out this.TurtleShellSledLoopSpeedParameter);
                 this.TurtleShellSledLoopInstance.getParameter("air", out this.TurtleShellSledLoopAirParameter);
                 this.TurtleShellSledLoopInstance.getParameter("snow", out this.TurtleShellSledLoopSnowParameter);
             }
         }
     }
     else
     {
         base.enabled = false;
     }
     if (this.Remote)
     {
         base.enabled = false;
         return;
     }
     this.prevPosition = base.GetComponent <Rigidbody>().position;
 }
    void OnDisable()
    {
        if (isInitialized)
        {
            FMOD.Studio.UnityUtil.Log("__ SHUT DOWN FMOD SYSTEM __");
            ERRCHECK(system.release());

            #if FMOD_DEBUG && UNITY_EDITOR
            if (logReader != null)
            {
                logReader.Close();
                logReader = null;
            }
            #endif

            if (this == sInstance)
            {
                sInstance = null;
            }
        }
    }
Beispiel #24
0
    void LoadPlugins()
    {
        FMOD.System sys = null;
        FMOD_StudioSystem.ERRCHECK(FMOD_StudioSystem.instance.System.getLowLevelSystem(out sys));

        var dir = pluginPath;

        foreach (var name in pluginPaths)
        {
            var path = dir + "/" + GetPluginFileName(name);

            //Debug.Log("Loading plugin: " + path);
            if (!System.IO.File.Exists(path))
            {
                Debug.LogWarning("plugin not found: " + path);
            }

            uint handle = 0;
            FMOD_StudioSystem.ERRCHECK(sys.loadPlugin(path, ref handle));
        }
    }
Beispiel #25
0
    public static void UnPreloadEvent(string path, int unloadCount)
    {
        if (FMOD_StudioSystem.sInstance == null)
        {
            return;
        }
        if (path.Length == 0)
        {
            return;
        }
        EventDescription eventDescription = FMOD_StudioSystem.sInstance.GetEventDescription(path);

        if (eventDescription == null)
        {
            UnityUtil.LogWarning("UnPreload failed for \"" + path + "\"");
            return;
        }
        for (int i = 0; i < unloadCount; i++)
        {
            FMOD_StudioSystem.ERRCHECK(eventDescription.unloadSampleData());
        }
    }
Beispiel #26
0
    public EventDescription GetEventDescription(string path)
    {
        if (string.IsNullOrEmpty(path))
        {
            UnityUtil.LogError("Empty event path!");
        }
        if (this.eventDescriptions.ContainsKey(path))
        {
            return(this.eventDescriptions[path]);
        }
        EventDescription eventDescription = null;
        RESULT           @event           = this.system.getEvent(path, out eventDescription);

        if (@event == RESULT.OK)
        {
            this.eventDescriptions.Add(path, eventDescription);
            return(eventDescription);
        }
        FMOD_StudioSystem.ERRCHECK(@event);
        UnityUtil.LogWarning("Error getting event with path \"" + path + "\"");
        return(null);
    }
Beispiel #27
0
 private void OnApplicationPause(bool pauseStatus)
 {
     if (this.system != null && this.system.isValid())
     {
         UnityUtil.Log("Pause state changed to: " + pauseStatus);
         FMOD.System system;
         FMOD_StudioSystem.ERRCHECK(this.system.getLowLevelSystem(out system));
         if (system == null)
         {
             UnityUtil.LogError("Tried to suspend mixer, but no low level system found");
             return;
         }
         if (pauseStatus)
         {
             FMOD_StudioSystem.ERRCHECK(system.mixerSuspend());
         }
         else
         {
             FMOD_StudioSystem.ERRCHECK(system.mixerResume());
         }
     }
 }
Beispiel #28
0
 public void UnloadAllEventsInstances()
 {
     UnityEngine.Debug.Log("<color=yellow>------------------------- UnloadAllEventsInstances -------------------------</color>");
     foreach (KeyValuePair <string, EventDescription> current in this.eventDescriptions)
     {
         EventInstance[] array;
         FMOD_StudioSystem.ERRCHECK(current.Value.getInstanceList(out array));
         if (array != null)
         {
             for (int i = 0; i < array.Length; i++)
             {
                 array[i].release();
             }
             UnityEngine.Debug.Log(string.Concat(new object[]
             {
                 "key: ",
                 current.Key,
                 " instance cnt:",
                 array.Length
             }));
         }
     }
 }
Beispiel #29
0
    public void OutputCurrEventsInfo()
    {
        UnityEngine.Debug.Log("<color=yellow>------------------------- OutputCurrEventsInfo -------------------------</color>");
        int num = 0;

        foreach (KeyValuePair <string, EventDescription> current in this.eventDescriptions)
        {
            int num2 = 0;
            FMOD_StudioSystem.ERRCHECK(current.Value.getInstanceCount(out num2));
            if (num2 > 0)
            {
                UnityEngine.Debug.Log(string.Concat(new object[]
                {
                    "key: ",
                    current.Key,
                    " instance cnt:",
                    num2
                }));
                num++;
            }
        }
        UnityEngine.Debug.Log("RESULT, CNT IS: " + num);
    }
Beispiel #30
0
 private void Start()
 {
     this.hashIdle            = Animator.StringToHash("idling");
     this.previousPosition    = base.transform.position;
     this.eventsByItemIdCache = new Dictionary <int, ItemGroupEvent>();
     if (FMOD_StudioSystem.instance)
     {
         this.sledEvent = FMOD_StudioSystem.instance.GetEvent(this.pushSledEvent);
         if (this.sledEvent != null)
         {
             this.sledEvent.getParameter("speed", out this.sledSpeedParameter);
         }
         if (this.Remote)
         {
             return;
         }
         ItemGroupEvent[] array = this.AllItemGroupEvents();
         for (int i = 0; i < array.Length; i++)
         {
             ItemGroupEvent itemGroupEvent = array[i];
             int[]          itemIds        = itemGroupEvent._itemIds;
             for (int j = 0; j < itemIds.Length; j++)
             {
                 int key = itemIds[j];
                 this.eventsByItemIdCache[key] = itemGroupEvent;
                 FMOD_StudioSystem.PreloadEvent(itemGroupEvent.eventPath);
             }
         }
         FMOD_StudioSystem.PreloadEvent(this.breatheInEvent);
         FMOD_StudioSystem.PreloadEvent(this.breatheOutEvent);
         FMOD_StudioSystem.PreloadEvent(this.fallEvent);
     }
     else
     {
         UnityEngine.Debug.LogError("FMOD_StudioSystem.instance is null, could not initialize animEventManager audio");
     }
 }
Beispiel #31
0
	void OnDisable()
	{
		if (isInitialized)
		{
			FMOD.Studio.UnityUtil.Log("__ SHUT DOWN FMOD SYSTEM __");
			ERRCHECK(system.release());

            #if FMOD_DEBUG && UNITY_EDITOR
            if (logReader != null)
            {
                logReader.Close();
                logReader = null;
            }   
            #endif

            if (this == sInstance)
            {
                sInstance = null;
            }
		}
	}
Beispiel #32
0
    void OnDisable()
    {
        if (isInitialized)
        {
            FMOD.Studio.UnityUtil.Log("__ SHUT DOWN FMOD SYSTEM __");
            ERRCHECK(system.release());

            if (this == sInstance)
            {
                sInstance = null;
            }
        }
    }