Пример #1
0
        void drawDefualt()
        {
            GUILayout.BeginHorizontal();

            GUILayout.Label("default", defaultLabel);

            //连接选择
            GUI.color = EditorGUIUtility.isProSkin ? Color.green : Color.grey;
            if (MyEditorLayout.Button("L", defaultLButton, out rect))
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(newNode, false, () =>
                {
                    var tempWindow = new NodeWindow(new Vector2(50, 50) + position, windowList);
                    windowList.Add(tempWindow);
                    defaultEntity = tempWindow;
                });

                List <BaseWindow> selectionList = new List <BaseWindow>();
                foreach (var item in windowList)
                {
                    if (item is NodeWindow)
                    {
                        selectionList.Add(item);
                    }
                }

                foreach (var item in selectionList)
                {
                    bool select = (defaultEntity != null) && defaultEntity.Id == item.Id;
                    menu.AddItem(new GUIContent(item.Id + " " + item.Name), select, () =>
                    {
                        if (select)
                        {
                            defaultEntity = null;
                        }
                        else
                        {
                            defaultEntity = item as NodeWindow;
                        }
                    });
                }

                menu.ShowAsContext();
            }

            if (defaultEntity == null)
            {
                linkStyle.normal.textColor = Color.gray;
            }
            else
            {
                linkStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.green : Color.grey;
            }

            MyEditorLayout.Label("o", linkStyle, out rect);

            //有的时候 rect会为0,0,1,1
            if (rect.position != Vector2.zero)
            {
                defaultPos.x = rect.position.x + rect.width;
                defaultPos.y = rect.position.y + rect.height / 2;
            }

            GUI.color = Color.white;

            GUILayout.EndHorizontal();
        }
Пример #2
0
        void drawConditions()
        {
            for (int i = 0; i < conditions.Count; i++)
            {
                RouterWindowCondition rc = conditions[i];
                GUILayout.BeginHorizontal();

                string c           = rc.className;
                int    selectindex = allConditionClass.IndexOf(c);
                selectindex = EditorGUILayout.Popup(selectindex, allConditionClass.ToArray(), popupStyle);
                if (selectindex >= 0)
                {
                    conditions[i].className = allConditionClass[selectindex];
                }

                //删除
                GUI.color = Color.red;
                if (GUILayout.Button("-", buttonStyle))
                {
                    conditions.RemoveAt(i);
                    i--;
                    _size.y -= addHeight;
                }
                GUI.color = Color.white;

                //连接选择
                GUI.color = EditorGUIUtility.isProSkin ? Color.green : Color.grey;
                if (MyEditorLayout.Button("L", buttonStyle, out rect))
                {
                    GenericMenu menu = new GenericMenu();

                    menu.AddItem(newNode, false, () =>
                    {
                        var tempWindow = new NodeWindow(new Vector2(50, 50) + position, windowList);
                        windowList.Add(tempWindow);
                        rc.entity = tempWindow;
                    });

                    menu.AddSeparator("");

                    List <NodeWindow> selectionList = new List <NodeWindow>();
                    foreach (var item in windowList)
                    {
                        if (item.windowType == NodeType.Node)
                        {
                            selectionList.Add(item as NodeWindow);
                        }
                    }

                    foreach (var item in selectionList)
                    {
                        bool select = (rc.entity != null) && rc.entity.Id == item.Id;
                        menu.AddItem(new GUIContent(string.Format("[{0}][{1}] {2}", item.Id, item.windowType, item.Name)), select, () =>
                        {
                            if (select)
                            {
                                rc.entity = null;
                            }
                            else
                            {
                                rc.entity = item;
                            }
                        });
                    }

                    menu.ShowAsContext();
                }


                GUI.color = Color.white;

                if (rc.entity == null)
                {
                    linkStyle.normal.textColor = Color.gray;
                }
                else
                {
                    linkStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.green : Color.grey;
                }

                MyEditorLayout.Label("o", linkStyle, out rect);

                //有的时候 rect会为0,0,1,1
                if (rect.position != Vector2.zero)
                {
                    rc.drawPos.x = rect.position.x + rect.width;
                    rc.drawPos.y = rect.position.y + rect.height / 2;
                }

                GUILayout.EndHorizontal();
            }
        }