Ejemplo n.º 1
0
    protected void Insertpoints(LPCorporeal poly, Event e)
    {
        Vector3 mousepos = GetMousePos(e);
        int     cID      = GetCID();

        int   closest = 0;
        float dist    = 0;

        if (!created)
        {
            isclosest = DrawLines(poly.transform, poly.GetPoints(), poly.transform.position, mousepos
                                  , cID, out closest, out dist, Color.green, poly.EditMe);
        }
        poly.ClosestDist = dist;
        CheckDists(poly);

        if (poly.EditMe)
        {
            switch (e.type)
            {
            case EventType.mouseDown:
                if (isclosest)
                {
                    Undo.RecordObject(poly, "Add Point to poly shape");
                    poly.InsertPoint(closest + 1, mousepos - poly.transform.position);
                    created                = true;
                    createdindex           = closest + 1;
                    EditingStatics.editing = true;
                }
                e.Use();
                break;

            case EventType.MouseDrag:
                if (created)
                {
                    poly.EditPoint(createdindex, mousepos - poly.transform.position);
                }

                e.Use();
                break;

            case EventType.MouseMove:
                e.Use();
                break;

            case EventType.mouseUp:
                created = false;
                EditingStatics.editing = false;
                e.Use();
                break;

            case EventType.layout:
                HandleUtility.AddDefaultControl(cID);
                break;
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
        }
    }
Ejemplo n.º 2
0
    protected void Movepoints(LPCorporeal poly, Event e)
    {
        Vector3 mousepos = GetMousePos(e);
        int cID = GetCID();

        if (!editing)
        {
            int closest;
            float dist;
            isclosest = CheckDists(poly.transform,poly.GetPoints(),poly.transform.position,mousepos,cID,out closest,out dist,Color.blue,poly.EditMe);
            poly.ClosestDist = dist;
            if (isclosest)
            {
                editpoint = closest;
            }
            if(!EditingStatics.editing)CheckDists(poly);
        }

        if (poly.EditMe)
        {
            switch (e.type)
            {
            case EventType.mouseDown:
                if (isclosest)
                {
                    Undo.RecordObject (poly,"Move Point in poly shape");
                    editing = true;
                    EditingStatics.editing = true;
                }
                e.Use();
                break;

            case EventType.mouseUp:
                if (editing)
                {
                    editing = false;
                    EditingStatics.editing = false;
                }
                e.Use();
                break;

            case EventType.MouseMove:
                e.Use();
                break;

                case EventType.MouseDrag:
                    e.Use();
                    break;

                case EventType.layout:
                    HandleUtility.AddDefaultControl(cID);
                    break;
            }
            if (GUI.changed) EditorUtility.SetDirty(target);

            if (editing)
            {
                poly.EditPoint(editpoint,mousepos - poly.transform.position);
            }
        }
    }
Ejemplo n.º 3
0
    protected void Movepoints(LPCorporeal poly, Event e)
    {
        Vector3 mousepos = GetMousePos(e);
        int     cID      = GetCID();

        if (!editing)
        {
            int   closest;
            float dist;
            isclosest        = CheckDists(poly.transform, poly.GetPoints(), poly.transform.position, mousepos, cID, out closest, out dist, Color.blue, poly.EditMe);
            poly.ClosestDist = dist;
            if (isclosest)
            {
                editpoint = closest;
            }
            if (!EditingStatics.editing)
            {
                CheckDists(poly);
            }
        }

        if (poly.EditMe)
        {
            switch (e.type)
            {
            case EventType.mouseDown:
                if (isclosest)
                {
                    Undo.RecordObject(poly, "Move Point in poly shape");
                    editing = true;
                    EditingStatics.editing = true;
                }
                e.Use();
                break;

            case EventType.mouseUp:
                if (editing)
                {
                    editing = false;
                    EditingStatics.editing = false;
                }
                e.Use();
                break;

            case EventType.MouseMove:
                e.Use();
                break;

            case EventType.MouseDrag:
                e.Use();
                break;

            case EventType.layout:
                HandleUtility.AddDefaultControl(cID);
                break;
            }
            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }

            if (editing)
            {
                poly.EditPoint(editpoint, mousepos - poly.transform.position);
            }
        }
    }
Ejemplo n.º 4
0
    protected void Insertpoints(LPCorporeal poly, Event e)
    {
        Vector3 mousepos = GetMousePos(e);
        int cID = GetCID();

        int closest = 0;
        float dist = 0;
        if (!created) isclosest = DrawLines(poly.transform,poly.GetPoints(),poly.transform.position,mousepos
                                                                        ,cID,out closest,out dist,Color.green,poly.EditMe);
        poly.ClosestDist = dist;
        CheckDists(poly);

        if (poly.EditMe)
        {
            switch (e.type)
            {
            case EventType.mouseDown:
                if (isclosest)
                {
                    Undo.RecordObject (poly,"Add Point to poly shape");
                    poly.InsertPoint(closest+1,mousepos-poly.transform.position);
                    created = true;
                    createdindex = closest+1;
                    EditingStatics.editing = true;
                }
                e.Use();
                break;

            case EventType.MouseDrag:
                if (created)poly.EditPoint(createdindex,mousepos - poly.transform.position);

                e.Use();
                    break;

            case EventType.MouseMove:
                e.Use();
                break;

            case EventType.mouseUp:
                created = false;
                EditingStatics.editing = false;
                e.Use();
                break;

                case EventType.layout:
                    HandleUtility.AddDefaultControl(cID);
                    break;
            }
            if (GUI.changed) EditorUtility.SetDirty(target);
        }
    }