# FMOD Studio "onBuild" hook does not allow to change the project

**URL:** <https://qa.fmod.com/t/fmod-studio-onbuild-hook-does-not-allow-to-change-the-project/18909>\
**Category:** FMOD Studio\
**Created:** [June 17, 2022, 8:40pm UTC](https://qa.fmod.com/t/fmod-studio-onbuild-hook-does-not-allow-to-change-the-project/18909 "2022-06-17T20:40:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![akita\_engineer](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@akita\_engineer](https://qa.fmod.com/u/akita_engineer)\
**Post date:** [June 17, 2022, 8:40pm UTC](https://qa.fmod.com/t/fmod-studio-onbuild-hook-does-not-allow-to-change-the-project/18909/1 "2022-06-17T20:40:33Z")

</div>

Hello there,

I’ve been using FMOD Studio for a while already and recently my team has decided to leverage the scripting engine included with FMOD Studio to export custom information about our events.

I created a simple script that exports all markers associated with every event, their name and time position by running some extra logic in “onBuild” hook - works like a charm.

I then appended that logic with a routine that adds a special marker to **each event in the project** - we need it for a couple of reasons. Here is where I ran into the problems:

- The marker would be added and it would be visible in the UI
- Upon reloading into the project the marker will be gone
- Version control also doesn’t detect any changes, the project title in FMOD Studio doesn’t have a (\*) indicating there were changes

In summary, the marker would be added but it would not be persistent and would only be available in this particular session.

**However** if I just create a special button that runs custom logic (without using onBuild hook), then the changes would be picked up by the FMOD Studio, Version control and etc.

For example, this is the scenario when the changes do get picked up:

```auto
studio.menu.addMenuItem({ 
  name: "Custom\\Generate Events",
  keySequence: "Shift+Ctrl+B",
  execute: function() {
      _generateEventStartedMarkersForAllEvents() // adds a custom marker 
      studio.project.build()
  },
});

function onBuild(success) {
  _exportEventInformation()
}

studio.project.buildEnded.connect(onBuild);

```

This is the scenario when changes **do not** get picked up

```auto
studio.menu.addMenuItem({ 
  name: "Custom\\Generate Events",
  keySequence: "Shift+Ctrl+B",
  execute: function() {
      studio.project.build()
  },
});

function onBuild(success) {
    _generateEventStartedMarkersForAllEvents() // adds a custom marker 
    _exportEventInformation()
}

studio.project.buildEnded.connect(onBuild);

```

As you can see, I can use the workaround for now where I build the project with the custom script which adds the markers so I am not blocked - however, is there something I am missing or is this a bug? It would be nice to put everything in the onBuild hook since then when we onboard other developers, they can just use the regular Build process rather than a special button that is hiding in the Scripts dropdown.

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [June 24, 2022, 6:37am UTC](https://qa.fmod.com/t/fmod-studio-onbuild-hook-does-not-allow-to-change-the-project/18909/2 "2022-06-24T06:37:30Z")

</div>

So the markers don’t persist after adding them through script during a buildEnded callback, but they do if they are added during a menu button callback? Are you finding other changes persist if they are added during a buildEnded callback?  
That does sound like a bug, what version of FMOD Studio are you using?

---

<div class="post-metadata">

**Author:** ![akita\_engineer](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@akita\_engineer](https://qa.fmod.com/u/akita_engineer)\
**Post date:** [October 14, 2022, 11:16pm UTC](https://qa.fmod.com/t/fmod-studio-onbuild-hook-does-not-allow-to-change-the-project/18909/3 "2022-10-14T23:16:57Z")

</div>

Sorry for the _very_ late reply. We shifted away from using this logic entirely, but no changes seemed to persist if they were added during buildEnded callback.

We are using version 2.02.04.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [October 18, 2022, 10:54pm UTC](https://qa.fmod.com/t/fmod-studio-onbuild-hook-does-not-allow-to-change-the-project/18909/4 "2022-10-18T22:54:47Z")

</div>

Hi,

I have confirmed this issue and will pass it onto our dev team. Thanks for brining it to our attention.
