Add Event in Unity Editor not work!

Hello, i can’t create new Event FMOD from Unity because i have many banks, so it meet error when BuildTree function in CreateEventPopup.cs

{
var rootGuid = EditorUtils.GetScriptOutput("studio.project.workspace.masterEventFolder.id");
rootFolder = new FolderEntry();
rootFolder.guid = rootGuid;
BuildTreeItem(rootFolder);
wantsMouseMove = true;
banks = new List();
        const string buildBankTreeFunc =
            @"function() {
                var output = """";
                const items = [ studio.project.workspace.masterBankFolder ];
                while (items.length > 0) {
                    var currentItem = items.shift();
                    if (currentItem.isOfType(""BankFolder"")) {
                        currentItem.items.reverse().forEach(function(val) {
                            items.unshift(val);
                        });
                    } else {
                        output += "","" + currentItem.id + currentItem.getPath().replace(""bank:/"", """");
                    }
                }
                return output;
            }";

        string bankList = EditorUtils.GetScriptOutput(string.Format("({0})()", buildBankTreeFunc));
        string[] bankListSplit = bankList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        foreach (var bank in bankListSplit)
        {
            var entry = new BankEntry();
            entry.guid = bank.Substring(0, 38);
            entry.name = bank.Substring(38);
            banks.Add(entry);
        }
    }`

when i increaseto bigger 2048 bytes in this function at EditorUtils, it works…

public static string GetScriptOutput(string command)
        {
            byte[] commandBytes = Encoding.UTF8.GetBytes(command);
            try
            {
                ScriptStream.Write(commandBytes, 0, commandBytes.Length);
                byte[] commandReturnBytes = new byte[2048];
                int read = ScriptStream.Read(commandReturnBytes, 0, commandReturnBytes.Length);
                string result = Encoding.UTF8.GetString(commandReturnBytes, 0, read - 1);
                if (result.StartsWith("out():"))
                {
                    return result.Substring(6).Trim();
                }
                return null;
            }
            catch (Exception)
            {
                networkStream.Close();
                networkStream = null;
                return null;
            }
        }

What should i do? many thanks!!

@Connor_FMOD can you help me please :frowning:

i meet error when add event in unity, but if i change function like this in EditorUtils.cs, it fixed

Thanks for reporting this, it does look like it’s possible to get an ArgumentOutOfRangeException as the Bank tree is built, if the entire list of bank strings is greater than the byte array in GetScriptOutput.

I have raised a task to investigate a solution for it but for now this is something that will need to be handled like you have shown.

okay, thank you for reply