/// <summary> /// Snaps to best non-null candidate. /// If candidate is null, removes from parent /// CurSnapCollidersInContact cannot be empty in this case /// or else bestCandidate would just be whatever is in that set /// </summary> private void EvaluateBestCandidateCollider() { if (bestCandidateSnapCollider != null) { bestCandidateSnapCollider.DoSnapAction(MyCodeBlock); } else { Assert.IsTrue(curSnapCollidersInContact.Empty()); MyCodeBlock.RemoveFromParentSnapCollider(true); } }
void OnManipulationEnd(ManipulationEventData call) { currentlyDraggingCBS = null; lastDraggedCBS = this; if (bestCandidateSnapCollider != null) { bestCandidateSnapCollider.DoSnapAction(bestCandidateSnapCollider.GetMyCodeBlock(), GetMyCodeBlock()); } else { // Remove when dragged away myCodeBlock.RemoveFromParentBlock(true); } mySnapColliders?.DisableAllCompatibleColliders(); GetCurSnapCollidersInContact().Clear(); AddSnapColliderInContact(null); }
void OnManipulationEnd(ManipulationEventData call) //let go of the block { currentlyDraggingCBS = null; lastDraggedCBS = this; if (bestCandidateSnapCollider != null) // within grey zone; SNAP ON { bestCandidateSnapCollider.DoSnapAction(bestCandidateSnapCollider.GetMyCodeBlock(), GetMyCodeBlock()); Block2TextConsoleManager.instance.UpdateConsoleOnSnap(); //refresh the Block2Text console when you ADD a block } else // outside of grey zone; SNAP OFF // Remove when dragged away { myCodeBlock.RemoveFromParentBlock(true); Block2TextConsoleManager.instance.UpdateConsoleOnSnap(); //refresh the Block2Text console when you REMOVE a block } mySnapColliders?.DisableAllCompatibleColliders(); GetCurSnapCollidersInContact().Clear(); AddSnapColliderInContact(null); }