예제 #1
0
 public ConnectBox(ConnectAreaType area, string name = "")
 {
     linkName = name;
     connectArea = area;
     boxRect = new Rect(0, 0, CONNECT_SIZE, CONNECT_SIZE);
     handle = HandleIndex;
     HandleIndex++;
 }
예제 #2
0
 public ConnectBox(ConnectAreaType area, string name = "")
 {
     linkName    = name;
     connectArea = area;
     boxRect     = new Rect(0, 0, CONNECT_SIZE, CONNECT_SIZE);
     handle      = HandleIndex;
     HandleIndex++;
 }
예제 #3
0
 /// <summary>
 /// GUI描画
 /// </summary>
 public override void OnDrawGUI()
 {
     if (edgeEnd == null)
     {
         ConnectAreaType type  = parentWindow.ActiveEdge.edgeStart.connact.connectArea == ConnectAreaType.AREA_LEFT ? ConnectAreaType.AREA_RIGHT : ConnectAreaType.AREA_LEFT;
         ConnectBox      mouse = new ConnectBox(type);
         mouse.boxRect = parentWindow.mouseData.rect;
         DrawNodeCurve(edgeStart.connact, mouse);
     }
     else if (edgeStart == null)
     {
         ConnectAreaType type  = parentWindow.ActiveEdge.edgeEnd.connact.connectArea == ConnectAreaType.AREA_LEFT ? ConnectAreaType.AREA_RIGHT : ConnectAreaType.AREA_LEFT;
         ConnectBox      mouse = new ConnectBox(type);
         mouse.boxRect = parentWindow.mouseData.rect;
         DrawNodeCurve(mouse, edgeEnd.connact);
     }
     else
     {
         DrawNodeCurve(edgeStart.connact, edgeEnd.connact);
     }
 }
예제 #4
0
        // ドラッグ処理
        public void windowFunc(int id)
        {
            Color[] TitleBarColor = new Color[] { Color.gray, new Color(0.4f, 0.4f, 0.8f),
                                                  Color.cyan, Color.green, Color.yellow, Color.magenta, Color.red };


            float zoom = windowRect.height / realWindowRect.height;

            // タイトルバー
            const int titleHeight = 16;
            Rect      title       = windowRect;

            title.position = new Vector2(-1, 0);
            title.height   = titleHeight * zoom;
            title.width   += 2;

            //GUI.color = TitleBarColor[0];// TitleBarColor[handle % (int)NodeColor.Max];

            GUIStyle style = new GUIStyle("dropDownButton");

            style.fontSize = (int)((titleHeight - 3) * zoom);
            //GUIStyleState styleState = new GUIStyleState();
            //styleState.textColor = Color.white;   // 文字色の変更.
            //style.normal = styleState;
            //style.fontStyle = FontStyle.Italic;
            style.fixedHeight = titleHeight * zoom;             // バー高さ


            //float add = 0.1f;
            //GUI.color = Color.HSVToRGB(add * (handle % (1.0f / add)), 0.8f, 0.6f);
            //GUI.color = EditorGUIUtility.HSVToRGB(add * (handle % (1.0f / add)), 0.8f, 0.6f);
            //GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1.0f);
            GUI.color = new Color(0.4f, 0.6f, 1.0f, 1.0f);
            GUI.Label(title, NodeName, style);

            //float centeroffset = (NodeName.Length/2 * style.fontSize);
            //GUIHelper.DrawText(new Vector2(title.width / 2 - centeroffset, 0), NodeName, Color.white);

            // コネクタ名
            foreach (var box in connectBoxList)
            {
                int  fontsize  = (int)((titleHeight - 5) * zoom);
                Rect labelRect = box.boxRect;
                int  length    = fontsize * box.linkName.Length;
                labelRect.x  = box.connectArea == ConnectAreaType.AREA_LEFT ? 5 : windowRect.width - length + 8;
                labelRect.y -= windowRect.y;

                GUIStyle connectstyle = new GUIStyle();
                connectstyle.fontSize = fontsize;
                GUI.Label(labelRect, box.linkName, connectstyle);
            }


            //----------------------
            // コネクタ追加
            //----------------------
            var ev = Event.current;

            if (ev.type == EventType.MouseDown && ev.button == 1)
            {
                // MyEditorWindow内のPopup Window上でマウスを右クリックするとここに来る。
                var             menu = new GenericMenu();
                ConnectAreaType type = ConnectAreaType.AREA_MAX;

                float offsety = windowRect.height / 4;
                float offsetx = windowRect.width / 4;
                if (ev.mousePosition.x < offsety && ev.mousePosition.y > offsety)
                {
                    type = ConnectAreaType.AREA_LEFT;
                }
                else if (ev.mousePosition.x >= windowRect.width - offsetx && ev.mousePosition.y > offsetx)
                {
                    type = ConnectAreaType.AREA_RIGHT;
                }
                else if (ev.mousePosition.y < offsety)
                {
                    type = ConnectAreaType.AREA_TOP;
                }
                else if (ev.mousePosition.y > windowRect.height - offsety)
                {
                    type = ConnectAreaType.AREA_BOTTOM;
                }
                if (type != ConnectAreaType.AREA_MAX)
                {
                    menu.AddItem(new GUIContent("Add Link"), false, () =>
                    {
                        AddConnectBox(new ConnectBox(type, "out"));
                    });
                }
                else
                {
                    menu.AddItem(new GUIContent("テスト"), false, () =>
                    {
                    });
                }

                menu.ShowAsContext();
                ev.Use();
            }


            if (active)
            {
                GUI.DragWindow();
            }
        }