private void Update() { transform.position = Input.mousePosition + offset; if (Shown) { Ray screenray = SceneGlobals.map_camera.ScreenPointToRay(Input.mousePosition); RaycastHit currenthit; if (Physics.Raycast(screenray, out currenthit)) { IAimable aimable = GetAimable(currenthit.transform); ShipPart part = (ShipPart)aimable; if (part != null) { // If target is part Object = new PartOffsetAim(currenthit.point, part); text.text = part.Name(); } else { DestroyableTarget dest_tgt = (DestroyableTarget)aimable; if (dest_tgt != null) { // If target is destroyable target Object = new PhysicsOffsetAim(currenthit.point, dest_tgt); text.text = part.Name(); } else { // void text.text = currenthit.transform.name; } } } else { Object = null; foreach (MapTgtMarker marker in MapTgtMarker.marker_list) { if (marker.RectTransform.rect.Contains((Vector2)Input.mousePosition - marker.Position)) { // If target is ship Object = marker.LinkedObject; text.text = marker.LinkedObject.Name; //Debug.DrawLine(Vector3.zero, Object.Position, Color.red, 100); } } if (Object == null) { // If no object selected text.text = ""; } } // Mousebutton unleashed if (!Input.GetMouseButton(0) && Dragging) { Dragging = false; switch (Context) { default: case PinContext.turret: break; case PinContext.selector: MapCore.Active.selector_event_system.DraggedTo(Object); break; } Context = PinContext.none; } } }