コード例 #1
0
    protected virtual void OnGUI()
    {
        GUILayout.BeginHorizontal();

        ScrollPosLeft = GUILayout.BeginScrollView(ScrollPosLeft,
                                                  GUILayout.Width(SplitterX),
                                                  GUILayout.MaxWidth(SplitterX),
                                                  GUILayout.MinWidth(SplitterX));
        LeftViewArea = new Rect(0, 0, SplitterX, Screen.height);
        OnGUILeftView();
        GUILayout.EndScrollView();

        GUILayout.Box("",
                      GUILayout.Width(SplitterWidth),
                      GUILayout.MaxWidth(SplitterWidth),
                      GUILayout.MinWidth(SplitterWidth),
                      GUILayout.ExpandHeight(true));
        Splitter = GUILayoutUtility.GetLastRect();
        EditorGUIUtility.AddCursorRect(Splitter, MouseCursor.ResizeHorizontal);

        ScrollPosRight = GUILayout.BeginScrollView(ScrollPosRight,
                                                   GUILayout.ExpandWidth(true));

        RightViewArea = new Rect(SplitterX, 0, Screen.width, Screen.height);
        OnGUIRightView();
        GUILayout.EndScrollView();

        GUILayout.EndHorizontal();

        if (Event.current != null)
        {
            if (Event.current.type == EventType.MouseDown)
            {
                if (Splitter.Contains(Event.current.mousePosition))
                {
                    Dragging = true;
                }
            }
            else if (Event.current.type == EventType.MouseDrag)
            {
                if (Dragging)
                {
                    SplitterX += Event.current.delta.x;
                    Repaint();
                }
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                Dragging = false;
            }
        }
    }