void Update()
 {
     if (!_PopupMode)
     {
         if (_CurrentObject != null)
         {
             Highlighter.UnHighLight(_CurrentObject);
             _CurrentObject = null;
         }
         if (_CurrentUnit != null)
         {
             Highlighter.UnHighLight(_CurrentUnit);
             _CurrentUnit = null;
         }
         if (Input.GetKeyDown("z"))
         {
             Settings.ZoneRod.SetActive(true);
         }
         if (Input.GetKeyUp("z") && _ZoneStartPoint == null)
         {
             Settings.ZoneRod.SetActive(false);
         }
         if (!EventSystem.current.IsPointerOverGameObject())             //Изучить. Непонятно что это, но работает
         {
             _CameraRay = _Camera.ScreenPointToRay(Input.mousePosition); //создаем луч, идущий из камеры через координаты мышки
             _IsHit     = Physics.Raycast(_CameraRay, out _Hit, 1000, mask);
             if (_IsHit)
             {
                 if (_Hit.transform.tag == "Brick")
                 {
                     if ((_BuildingMode) && (_Hit.transform.gameObject != _CurrentObject))
                     {
                         _PhantomBuilding.Hide();
                         _PhantomBuilding.Show(_Hit.transform.position);
                     }
                     _CurrentObject = _Hit.transform.gameObject;
                     Highlighter.HighLight(_CurrentObject);
                     if (Settings.ZoneRod.activeInHierarchy)
                     {
                         Settings.ZoneRod.transform.SetParent(_CurrentObject.transform, false);
                     }
                 }
                 if (_Hit.transform.tag == "Unit")
                 {
                     _CurrentUnit = _Hit.transform.gameObject;
                     Highlighter.HighLight(_CurrentUnit);
                 }
             }
             if (Input.GetMouseButtonDown(0))
             {
                 if (PickedObject != null)
                 {
                     Highlighter.UnPick(PickedObject);
                 }
                 if (_IsHit)
                 {
                     if (_Hit.transform.tag == "Brick" && _BuildingMode)
                     {
                         new ProcessManager.Building(_PhantomBuilding);
                         //Building _b = new Building(_BuildingSelectionDD.value, _PhantomBuilding.Rotation, _PhantomBuilding.MasterObject.transform.position);
                         //_PhantomBuilding.Destroy();
                         //Brick_intreraction_script.AddBuilding(_b);
                         _PhantomBuilding = null;
                         _BuildingMode    = false;
                     }
                     else
                     {
                         if (Settings.ZoneRod.activeInHierarchy) //В режиме выбора зоны
                         {
                             if (_ZoneStartPoint == null)        //Стартовая точка не задана
                             {
                                 _ZoneStartPoint = Instantiate(Settings.ZoneRod);
                                 _ZoneStartPoint.transform.SetParent(_CurrentObject.transform, false);
                             }
                             else //Стартовая точка задана
                             {
                                 //_ZoneEndPoint = Settings.ZoneRod; Пока написана херня для теста
                                 _ZoneEndPoint = Instantiate(Settings.ZoneRod);
                                 _ZoneEndPoint.transform.SetParent(_CurrentObject.transform, false);
                                 Settings.ZoneRod.SetActive(false);
                                 Links.Interface.SwitchToZoneMenu(0);
                             }
                         }
                         PickedObject = _Hit.transform.gameObject;
                         PickedObject.BroadcastMessage("Click");
                         Highlighter.Pick(PickedObject);
                         _Normal = _Hit.normal;
                         Log.Notice(scr + scrm, "Picked Object : " + PickedObject.name);
                     }
                 }
                 else
                 {
                     PickedObject = null;
                     Settings.ZoneRod.SetActive(false);
                     Destroy(_ZoneStartPoint);
                 }
             }
         }
         if (Input.GetKeyDown("a"))
         {
             if (PickedObject != null && PickedObject.tag == "Unit")
             {
                 if (_ActorUnit != null)
                 {
                     Highlighter.UnPick(_ActorUnit);
                 }
                 _ActorUnit   = PickedObject;
                 PickedObject = null;
                 Highlighter.BrightPick(_ActorUnit);
             }
             else
             {
                 if (_ActorUnit != null)
                 {
                     Highlighter.UnPick(_ActorUnit);
                 }
                 _ActorUnit = null;
             }
         }
         if (Input.GetKeyDown("r"))
         {
             if (_PhantomBuilding != null)
             {
                 _PhantomBuilding.Rotate();
             }
         }
         if (Input.GetMouseButton(1) && _ActorUnit != null)
         {
             Log.Notice(scr, "Walking");
             if ((_IsHit) && (_Hit.normal == Vector3.up))
             {
                 //_Normal.x = Mathf.RoundToInt(_Hit.point.x);
                 //_Normal.z = Mathf.RoundToInt(_Hit.point.z);
                 //_Normal.y = _Hit.point.y;
                 Log.Notice(scr, "Waybuilder call");
                 //_ActorUnit.GetComponent<RouteBuilder>().Build(_Normal);
                 _ActorUnit.GetComponent <Unit>().GoTo(_Hit.point);
             }
         }
         if (Input.GetMouseButton(1))//Massive reject
         {
             _BuildingMode = false;
             if (_PhantomBuilding != null)
             {
                 _PhantomBuilding.Destroy();
                 _PhantomBuilding = null;
             }
             CancelZoneCreation();
         }
         if (PickedObject != null && PickedObject.tag == "Unit" && Input.GetKey("l"))
         {
             PickedObject.GetComponent <RouteBuilder>().LogRoute();
         }
         if (Input.GetKey("o"))
         {
             if (!(PickedObject == null || PickedObject.tag == "Unit"))
             {
                 CreateUnit(PickedObject.transform.position);
                 Highlighter.UnPick(PickedObject);
                 PickedObject = null;
             }
             else
             {
                 Log.Notice(scr, "There is no picked cube");
             }
         }
     }
     else // Popup is open
     {
     }
 }