private void SetRightAndLeftButton(SearchPanel searchPanel) { _buttonLeft.onClick.RemoveAllListeners(); _buttonLeft.onClick.AddListener(delegate { if (_backGroundData.Sprites.Length - 1 > _backGroundIndex) { _backGroundIndex++; } else if (_backGroundData.Sprites.Length - 1 <= _backGroundIndex) { _backGroundIndex = 0; } ChangeBackGroundForIndex(_backGroundIndex); searchPanel?.SetRoomLayout(_backGroundIndex); }); _buttonRight.onClick.RemoveAllListeners(); _buttonRight.onClick.AddListener(delegate { if (_backGroundIndex > 0) { _backGroundIndex--; } else if (_backGroundIndex <= 0) { _backGroundIndex = _backGroundData.Sprites.Length - 1; } ChangeBackGroundForIndex(_backGroundIndex); searchPanel?.SetRoomLayout(_backGroundIndex); }); }