Exemplo n.º 1
0
    void ContextMenu()
    {
        GenericMenu menu = new GenericMenu();

        menu.AddItem(new GUIContent("Create Procedure"), false, () => {
            Procedure p = new Procedure(index, new Rect(e.mousePosition.x, e.mousePosition.y, 300, 250));
            procedure.Add(p);
            p.drawBezier += v => {
                BezierInfo info = new BezierInfo();
                info.startPos   = v;
                info.isDrawing  = true;
                curBezier       = info;
            };
            index++;
        });
        menu.ShowAsContext();
    }
Exemplo n.º 2
0
    void DrawBezier()
    {
        //绘制已经完成的贝塞尔
        for (int i = 0; i < list.Count; i++)
        {
            BezierInfo info = list[i];
            info.DrawBeziered();
        }

        //绘制中的贝塞尔
        if (curBezier != null && curBezier.isDrawing)
        {
            Vector3 endPos = new Vector3(e.mousePosition.x, e.mousePosition.y, 0);
            curBezier.DrawingBeziering(endPos);
            if (e.type == EventType.MouseUp)
            {
                curBezier.endPos    = endPos;
                curBezier.isDrawing = false;
                list.Add(curBezier);
                curBezier = null;
            }
            Repaint();
        }
    }