Skip to content

Add Event in Unity Editor not work!! #49

@anhnguyenSb

Description

@anhnguyenSb

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

`private void BuildTree()
{
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 increase byte to bigger, 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;
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions