void Update() { //if unit is not selected if (!Selected) { ScreenPos = Camera.main.WorldToScreenPoint(this.transform.position); if (MousePoint.UnitWithinScreenSpace(ScreenPos)) { if (!OnScreen) { //Debug.Log ("Adding this to screen: " + this); MousePoint.UnitsOnScreen.Add(this.gameObject); OnScreen = true; } } else { //remove object if previously on screen if (OnScreen) { MousePoint.RemoveFromOnScreenUnits(this.gameObject); } } } }