many collisions while holding an item

Hello all,

I’m sending a massage to the log file when I pick an Item with HTC Vive controller.
in my log file I get this:

Picked item, name : AppleRed at: 6/25/2017 5:43:17 PM

Picked item, name : AppleRed at: 6/25/2017 5:43:17 PM

Picked item, name : AppleRed at: 6/25/2017 5:43:18 PM

Picked item, name : AppleRed at: 6/25/2017 5:43:18 PM

Picked item, name : AppleRed at: 6/25/2017 5:43:18 PM

I understand that it might be because it counts several collision per frame, while I hold the item with the controller, can this be fixed?

I attach the script for reference.

    private void SetCollidingObject(Collider col)
    {
        if (collidingObject || !col.GetComponent<Rigidbody>())
        {
            return;
        }
      collidingObject = col.gameObject;

     if (col.gameObject.tag == "Item")
        {
            LogManager.AddLine("

" + "Picked item, name : " + col.gameObject.name);
}
}

Maybe try something like this…

    bool m_CollisionEnabled = true;
    void OnCollisionEnter(Collision collision)
    {
        if (m_CollisionEnabled)
        {
            m_CollisionEnabled = false;

            //Insert Functions Inbetween

            StartCoroutine(EnableCollision());
        }
    }

    IEnumerator EnableCollision()
    {
        yield return new WaitForEndOfFrame();
        m_CollisionEnabled = true;
    }