public void Deselect() { // Is there a selected object? if (CurrentSelectable != null) { // Deselect it CurrentSelectable.Deselect(); // Mark it null CurrentSelectable = null; } }
// Deselect the specified selectable, if it exists public void Deselect(LeanSelectable selectable) { // Loop through all current selectables if (CurrentSelectables != null) { for (var i = CurrentSelectables.Count - 1; i >= 0; i--) { var currentSelectable = CurrentSelectables[i]; if (currentSelectable != null) { // Match? if (currentSelectable == selectable) { selectable.Deselect(); CurrentSelectables.Remove(selectable); return; } } else { CurrentSelectables.RemoveAt(i); } } } }
private void SelectGlobal(LeanSelectable selectable, LeanFinger finger) { if (waitingForSelection == true) { selectingFinger = finger; lastSelectable = selectable; } else if (finger == selectingFinger) { // Good selection? if (MaximumSeparation <= 0.0f || lastSelectable == null || Vector3.Distance(lastSelectable.transform.position, selectable.transform.position) <= MaximumSeparation) { lastSelectable = selectable; } // Too far to select? else { selectable.Deselect(); } } }
private void SelectGlobal(LeanSelectable selectable, LeanFinger finger) { if (waitingForSelection == true) { LeanFingerData.FindOrCreate(ref fingerDatas, finger); } var fingerData = LeanFingerData.Find(fingerDatas, finger); if (fingerData != null) { // Good selection? if (MaximumSeparation <= 0.0f || fingerData.LastSelectable == null || Vector3.Distance(fingerData.LastSelectable.transform.position, selectable.transform.position) <= MaximumSeparation) { fingerData.LastSelectable = selectable; } // Too far to select? else { selectable.Deselect(); } } }
public void Select(LeanFinger finger, LeanSelectable selectable) { // Something was selected? if (selectable != null && selectable.isActiveAndEnabled == true) { if (selectable.HideWithFinger == true) { for (var i = CurrentSelectables.Count - 1; i >= 0; i--) { var currentSelectable = CurrentSelectables[i]; if (currentSelectable.HideWithFinger == true && currentSelectable.IsSelected == true) { return; } } } // Did we select a new LeanSelectable? if (IsSelected(selectable) == false) { // Deselect some if we have too many if (MaxSelectables > 0) { var extras = CurrentSelectables.Count - MaxSelectables + 1; for (var i = extras - 1; i >= 0; i--) { var currentSelectable = CurrentSelectables[i]; currentSelectable.Deselect(); CurrentSelectables.RemoveAt(i); } } // Add to selection and select CurrentSelectables.Add(selectable); selectable.Select(finger); } // Did we reselect the current LeanSelectable? else { switch (Reselect) { case ReselectType.Deselect: { selectable.Deselect(); CurrentSelectables.Remove(selectable); } break; case ReselectType.DeselectAndSelect: { // Change current selectable.Deselect(); // Call select event on current selectable.Select(finger); } break; case ReselectType.SelectAgain: { // Call select event on current selectable.Select(finger); } break; } } } // Nothing was selected? else { // Deselect? if (AutoDeselect == true) { DeselectAll(); } } }
public void Select(LeanFinger finger, LeanSelectable selectable) { // Something was selected? if (selectable != null && selectable.isActiveAndEnabled == true) { if (selectable.HideWithFinger == true) { foreach (var otherSelectable in LeanSelectable.Instances) { if (otherSelectable.HideWithFinger == true && otherSelectable.IsSelected == true) { return; } } } // Did we select a new LeanSelectable? if (selectable.IsSelected == false) { // Deselect some if we have too many if (MaxSelectables > 0) { LeanSelectable.Cull(MaxSelectables - 1); } // Select selectable.Select(finger); } // Did we reselect the current LeanSelectable? else { switch (Reselect) { case ReselectType.Deselect: { selectable.Deselect(); } break; case ReselectType.DeselectAndSelect: { selectable.Deselect(); selectable.Select(finger); } break; case ReselectType.SelectAgain: { selectable.Select(finger); } break; } } } // Nothing was selected? else { // Deselect? if (AutoDeselect == true) { DeselectAll(); } } }
public void Select(LeanFinger finger, LeanSelectable selectable) { //Debug.Log( "Select() finger = " + finger + ", selectable = " + selectable ); // Something was selected? if (selectable != null && selectable.isActiveAndEnabled == true) { if (selectable.HideWithFinger == true) { for (var i = LeanSelectable.Instances.Count - 1; i >= 0; i--) { var instance = LeanSelectable.Instances[i]; if (instance.HideWithFinger == true && instance.IsSelected == true) { return; } } } // Did we select a new LeanSelectable? if (selectable.IsSelected == false) { // Deselect some if we have too many if (MaxSelectables > 0) { LeanSelectable.Cull(MaxSelectables - 1); } // Select selectable.Select(finger); } // Did we reselect the current LeanSelectable? else { switch (Reselect) { case ReselectType.Deselect: { selectable.Deselect(); } break; case ReselectType.DeselectAndSelect: { selectable.Deselect(); selectable.Select(finger); } break; case ReselectType.SelectAgain: { selectable.Select(finger); } break; } } } // Nothing was selected? else { // Deselect? if (AutoDeselect == true) { DeselectAll(); } } }
// Deselect and remove without null checks private void DeselectAndRemove(LeanSelectable selectable) { selectable.Deselect(); CurrentSelectables.Remove(selectable); }