public void AddGameButton(GameInfo gInfo, Texture2D texture) { // Increment the amount of buttons _buttonAmount++; // Is a new row necessary? if (_buttonAmount % _BUTTONS_PER_ROW == 0 || _buttonAmount == 1) { CreateNewRow(); } // Instantiation GameObject newButton = Instantiate(_gameButtonPrefab); // Assigning Texture newButton.GetComponent <RawImage>().texture = texture; // Getting script GameButton buttonScript = newButton.GetComponent <GameButton>(); // Setting Game Info buttonScript.SetGameInfo(gInfo); // Adding to row _currentRow.AddToRow(buttonScript); }