private void QuadMapUpdate() { if (Input.GetMouseButtonDown(1)) { _mouse_point = GetPointOnPlaneByMousePosition(); if (_quad_map.IsEmpty()) { _cube_obj = Instantiate(_cube_prefab); CUnit unit = new CUnit(_cube_obj, _mouse_point, _box_size_min, _box_size_max, CIdGen.Instance.GetNewId()); _quad_map.InsertObject(unit); } else { _quad_map.DeleteObjectByMousePos(_mouse_point); } } if (Input.GetMouseButtonDown(2)) { _mouse_point = GetPointOnPlaneByMousePosition(); _cube_obj = Instantiate(_cube_prefab); CUnit unit = new CUnit(_cube_obj, _mouse_point, _box_size_min, _box_size_max, CIdGen.Instance.GetNewId()); _quad_map.InsertObject(unit); } if (Input.GetMouseButtonDown(0) && !_is_dragging) { if (_quad_map.IsEmpty()) { return; } _last_mouse_pos = GetPointOnPlaneByMousePosition(); _quad_map.SelectObjects(_last_mouse_pos, _selected_objects); if (_selected_objects.Count == 0) { return; } _selected_object = (CUnit)_selected_objects[0]; _selected_objects.Clear(); _is_dragging = true; } if (Input.GetMouseButton(0)) { if (_selected_object == null) { return; } _mouse_point = GetPointOnPlaneByMousePosition(); Vector3 offset = _mouse_point - _last_mouse_pos; Bounds old_aabb = _selected_object.GetAABB(); _selected_object.ChangeCenter(new Vector3(_selected_object.GetAABB().center.x + offset.x, 0, _selected_object.GetAABB().center.z + offset.z)); _quad_map.ChangeTreeOnMove(old_aabb, _selected_object); _last_mouse_pos = GetPointOnPlaneByMousePosition(); } if (Input.GetMouseButtonUp(0)) { _is_dragging = false; _selected_object = null; } }