# FMOD Scripting: Is it possible to edit the color of events/folders

**URL:** <https://qa.fmod.com/t/fmod-scripting-is-it-possible-to-edit-the-color-of-events-folders/19272>\
**Category:** FMOD Studio\
**Created:** [September 13, 2022, 6:37am UTC](https://qa.fmod.com/t/fmod-scripting-is-it-possible-to-edit-the-color-of-events-folders/19272 "2022-09-13T06:37:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![deHaan](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/dehaan/32/68_2.png) [@deHaan](https://qa.fmod.com/u/deHaan)\
**Post date:** [September 13, 2022, 6:37am UTC](https://qa.fmod.com/t/fmod-scripting-is-it-possible-to-edit-the-color-of-events-folders/19272/1 "2022-09-13T06:37:30Z")

</div>

I am slowly trying to learn scripting for FMOD, and was wondering if there is a way to modify the color of an event? I’d love to make a script that got the color of e.g. the “oldest” parent folder, and applied that to all its children (kind of how colors work in Wwise)

---

<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:** [September 15, 2022, 12:53am UTC](https://qa.fmod.com/t/fmod-scripting-is-it-possible-to-edit-the-color-of-events-folders/19272/2 "2022-09-15T00:53:00Z")

</div>

Hi,

Here is a script that will assign the color of the current selected object to all of its children:

> **Set Children Colour**
>
> ```auto
> 
> //Menu item to select in Studio
> studio.menu.addMenuItem({
> name: "Set Children Color",
> execute: function() { SetChildrenColor(); }
> })
> 
> //Function to set the child objects color to the current selected object color 
> function SetChildrenColor() {
> var currentSelection = studio.window.browserCurrent(); 
> if (currentSelection == null)
> {
> alert("Please select an object");
> return; 
> }
> 
> if (currentSelection.items.length == 0)
> {
> alert("Current object has no child Items"); 
> return; 
> }
> else 
> {
> for (var i = 0; i < currentSelection.items.length; i++) {
> FindBaseChild(currentSelection.items[i], currentSelection);             
> }
> }
> }
> 
> //Recursive function to find children
> function FindBaseChild(child, parent)
> {
> if (child.items.length == 0)
> {
> child.color = parent.color; 
> return; 
> }
> else 
> {
> child.color = parent.color;
> for (var i = 0; i < child.items.length; i++) {
> FindBaseChild(child.items[i], child);
> }
> }  
> }
> 
> ```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![deHaan](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/dehaan/32/68_2.png) [@deHaan](https://qa.fmod.com/u/deHaan)\
**Post date:** [September 15, 2022, 8:52am UTC](https://qa.fmod.com/t/fmod-scripting-is-it-possible-to-edit-the-color-of-events-folders/19272/3 "2022-09-15T08:52:36Z")

</div>

Wow thank you Connor, super helpful!!

I just made me own little variation to it, so it only colors “uncolored” children (my first FMOD scripting, yay): [FMOD - Color Children From Parent - YouTube](https://youtu.be/3tFmj1E55ks)

```auto
//Menu item to select in Studio
studio.menu.addMenuItem({
    name: "Color Uncolored Children",
    keySequence: "Ctrl+Shift+J",
    execute: function() { ColorUncoloredChildren(); }
})

//Function to set the child objects color to the current selected object color 
function ColorUncoloredChildren() {
    var currentSelection = studio.window.browserCurrent(); 
    if (currentSelection == null)
    {
        alert("Please select an object");
        return; 
    }

    if (currentSelection.items.length == 0)
    {
        alert("Current object has no child Items"); 
        return; 
    }
    else 
    {
        for (var i = 0; i < currentSelection.items.length; i++) {
            FindBaseChild(currentSelection.items[i], currentSelection);             
        }
    }
}

//Recursive function to find children
function FindBaseChild(child, parent)
{
    //alert(parent.color);
    if (child.color == "Default")
    {
        if (child.items.length == 0) {
            child.color = parent.color;
            return;
        }
        else {
            child.color = parent.color;
            for (var i = 0; i < child.items.length; i++) {
                FindBaseChild(child.items[i], child);
            }
        }  
    } 
}

```

---

<div class="post-metadata">

**Author:** ![deHaan](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/dehaan/32/68_2.png) [@deHaan](https://qa.fmod.com/u/deHaan)\
**Post date:** [October 4, 2022, 6:42am UTC](https://qa.fmod.com/t/fmod-scripting-is-it-possible-to-edit-the-color-of-events-folders/19272/4 "2022-10-04T06:42:36Z")

</div>

Hi @Connor_FMOD . I tried expanding the script to make it work on parameterpresets, effect presets etc. I have some of it working now, but I am stuck with the asset browser and mixer where I get this error:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/9/9a78b9386423f054afef643b637e1b12b9ea4155.png)

It seems like `items.length` does not work for MixerGroup or EncodableAsset enities which is what I see in these windows. Any ideas for how to work with this?

This is where I get the error:

 ![Screenshot 2022-10-04 at 08.43.22](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/9/9bde877affa2b5229d1aaa45d5de867146443862.jpeg)

Thank you!

---

<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 10, 2022, 12:04am UTC](https://qa.fmod.com/t/fmod-scripting-is-it-possible-to-edit-the-color-of-events-folders/19272/5 "2022-10-10T00:04:35Z")

</div>

Hi,

The structure for a Mixer group is a bit different from that of a Folder. To see a Mixer groups structure, open the console window found on the `FMOD Toolbar -> Window -> Console` or Ctrl-0 in Studio. While having a Mixer group selected use the command `studio.window.browserCurrent().dump()` in the console. This will display all available variables and functions attached to the currently selected item. The Mixer group variable you are looking for is `input`, use the same `for loop` but change `items` for `input`.

Keep in mind when changing the color of a `Mixer Input` you will have to access its `event`. To do so when looping through the `browerCurrent().input` check if `input.event != null` if true then use `input.event.color = "new Color"`

If you have any troubles I can share my code!

Hope this helps
