private void OnTriggerStay2D(Collider2D other) { if (host) { if (other.GetInstanceID() != subjectColliderID) { return; } } if (occupied) //if it is occupied { if (!obj.isCentered) //and our object is not centered { obj.Center(this.transform.position); //we will center it } } else //if it is not occupied { Drag_obj otherDrag = other.GetComponent <Drag_obj>(); if ((type == otherDrag.type) || (type == "")) //if it our type { obj = otherDrag; //it is ours now occupied = true; obj.Center(this.transform.position); //and we will center it obj.centeringNow = true; } } }
IEnumerator TakeBack() { while (gesture.ActiveTouches.Count != 0) { yield return(new WaitForEndOfFrame()); } if (gesture.ActiveTouches.Count == 0) // if we are not holding { if (obj.hasReachedDestination == false) //if object has not reached destination { obj.Center(transform.position); //center it yield break; } else { this.GetComponent <Slot>().occupied = false; //else free slot this.GetComponent <Slot>().obj = null; } } //return null; }