Exemplo n.º 1
0
    void OnGUI()
    {
        // hook to this window
        if (webView.Hook(this))
        {
            // do the first thing to do
            webView.LoadHTML(Compose());
        }

        var half = position.width / 2;

        // head/body/css/js
        var rect = new Rect(0, 0, (half - 50) / 4, 30);

        EditorGUI.BeginChangeCheck();
        for (int i = 0; i < 4; i++)
        {
            if (GUI.Toggle(rect, i == panel, Styles.heads[i], Styles.headStyles[i]))
            {
                panel = i;
            }
            rect.x += rect.width;
        }

        if (GUI.Button(new Rect(half - 45, 0, 45, 30), "Copy"))
        {
            GUIUtility.systemCopyBuffer = Compose().Replace("\n", Environment.NewLine);
        }

        if (EditorGUI.EndChangeCheck())
        {
            // need this so text field can be updated
            GUIUtility.keyboardControl = -1;
        }

        // html text field
        EditorGUI.BeginChangeCheck();
        this[panel] = EditorGUI.TextArea(new Rect(0, 30, half, position.height - 30), this[panel], Styles.textArea);
        if (EditorGUI.EndChangeCheck())
        {
            webView.LoadHTML(Compose());
        }

        if (Event.current.type == EventType.Repaint)
        {
            // keep the browser aware with resize
            webView.OnGUI(new Rect(half, 0, half, position.height));
        }
    }
Exemplo n.º 2
0
    void OnGUI()
    {
        // hook to this window
        if (webView.Hook(this))
        {
            // do the first thing to do
            webView.LoadHTML(Compose());
        }

        var half = new Rect(0, 0, position.width / 2, position.height);

        // html text field
        EditorGUI.BeginChangeCheck();
        data = EditorGUI.TextArea(half, data);
        if (EditorGUI.EndChangeCheck())
        {
            // push changes to webView and notify our input
            hook.Update();
            webView.ExecuteJavascript("update()");
        }

        half.x += half.width;

        if (Event.current.type == EventType.Repaint)
        {
            // keep the browser aware with resize
            webView.OnGUI(half);
        }
        else if (half.Contains(Event.current.mousePosition))
        {
            GUIUtility.keyboardControl = 0;
        }
    }