コード例 #1
0
    void PushVecocityShape()
    {
        if (select == null)
        {
            if (Input.GetMouseButtonDown(0))
            {
                ShapeObject[] shapes = ShapesCollision.OverlapPoint(mousePoint);
                if (shapes.Length <= 0)
                {
                    return;
                }

                select = shapes[0];
            }
        }
        else
        {
            mouseOffset = mousePoint - select.Position;

            text.text = mouseOffset.magnitude.ToString();
            text.transform.position = mousePoint;
            Debug.DrawLine(select.Position, mousePoint);

            if (Input.GetMouseButtonUp(0))
            {
                select.Velocity = (-mouseOffset);
                select          = null;
            }
        }
    }
コード例 #2
0
    void DragShape()
    {
        if (select != null)
        {
            select.Position = mouseOffset + mousePoint;
            select.SetColor(Color.white);
            select.RigidbodyType = RigidbodyType.Kinmatic;
        }
        else
        {
            ShapeObject[] shapes = ShapesCollision.OverlapPoint(mousePoint);
            if (shapes.Length <= 0)
            {
                return;
            }
            if (shapes[0].RigidbodyType == RigidbodyType.Static)
            {
                return;
            }

            select      = shapes[0];
            selectType  = select.RigidbodyType;
            mouseOffset = select.Position - mousePoint;
        }
    }