Crown.Exec C# (CSharp) Метод

Exec() публичный статический Метод

public static Exec ( string msg ) : void
msg string
Результат void
    public static void Exec(string msg)
    {
        Log("> " + msg);

        // Get name and arguments
        string[] msgParts = msg.Split(' ');
        string cmdName = "Console" + msgParts[0];
        string[] cmdArgsList = null;

        if (msgParts.Length > 1)
        {
            cmdArgsList = msgParts[1].Split(',');
        }

        // Send message to all modules
        BroadcastToAll(cmdName, cmdArgsList);
    }

Usage Example

Пример #1
0
    void OnGUI()
    {
        if (!display)
        {
            return;
        }

        // Display window
        wnd = GUILayout.Window(-1, wnd, WndDisplay, "CrownEngine Console");

        // Keyboard control
        if (Event.current.type == EventType.KeyUp)
        {
            // On TextField focus
            if (GUI.GetNameOfFocusedControl() == "TextField")
            {
                // Execute on Enter
                if (Event.current.keyCode == KeyCode.Return && wndTextField != "")
                {
                    Crown.Exec(wndTextField);
                    lastText.Add(wndTextField);
                    lastTextId   = lastText.Count;
                    wndTextField = "";
                }
                // List input story on up and down arrows
                if (lastText.Count > 0)
                {
                    // Previues text on up arrow
                    if (Event.current.keyCode == KeyCode.UpArrow)
                    {
                        if (lastTextId > 0)
                        {
                            lastTextId--;
                        }
                        wndTextField = lastText[lastTextId] as string;
                    }
                    // Next text on down arrow
                    else if (Event.current.keyCode == KeyCode.DownArrow)
                    {
                        if (lastTextId < lastText.Count - 1)
                        {
                            lastTextId++;
                            wndTextField = lastText[lastTextId] as string;
                        }
                        else
                        {
                            wndTextField = "";
                        }
                    }
                }
            }

            // Hide console on Escape button
            if (Event.current.keyCode == KeyCode.Escape)
            {
                display = false;
            }
        }
    }