// Called once in its life time private void Awake() { this.cursor = this.GetComponent <Image>(); this.rectTransform = this.GetComponent <RectTransform>(); this.mouseScreenBehaviour = this.GetComponent <MouseScreenBehaviour>(); this.mouseSelectionBehaviour = this.GetComponent <MouseSelectionBehaviour>(); this.mousePosition = new MousePosition(); }
/** * <summary> * On left mouse up * </summary> * * <returns> * void * </returns> */ private void OnLeftMouseUp() { // Stop scrolling, if the mouse is over UI or in build mode. if (!this.drag) { return; } // Is pointer up on the component panels UI, stop the selection if (ComponentPanelsUI.OnUI) { this.drag = false; this.HideSelectionArea(); return; } RectTransform areaRect = this.area.GetComponent <RectTransform>(); // Set final mouse position this.mousePosition.SetFinalPosition(this.transform.position); Bounds cameraViewportBounds = MouseScreenBehaviour.GetViewportBounds( this.mousePosition.GetInitialPosition(), this.mousePosition.GetFinalPosition() ); ResourcesManagerBehaviour.UnselectResource(); BuildingsManagerBehaviour.UnselectBuilding(); UnitsManagerBehaviour.UnselectGameObjects(); this.mouseSelectionBehaviour.SelectGameObjects(UnitsManagerBehaviour.Visibles, cameraViewportBounds); this.drag = false; this.HideSelectionArea(); }