with your recent code, if you keep pressing lower, the max and min will be smaller than what it should be. And if you keep pressing higher button, the min will be greater than max. So I’ve changed something here in NextGuess():
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class NumberWizard : MonoBehaviour
{
[SerializeField] int max;
[SerializeField] int min;
[SerializeField] TextMeshProUGUI guessText;
int guess;
// Use this for initialization
void Start()
{
StartGame();
}
void StartGame()
{
NextGuess();
}
public void OnPressHigher()
{
min = guess+1;
NextGuess();
Random.Range(max, guess);
}
public void OnPressLower()
{
max = guess-1;
NextGuess();
Random.Range(min, guess);
}
// Update is called once per frame
void NextGuess()
{
if (min > max)
{
min = max;
}
if (max <= min)
{
min = guess;
}
guess = Random.Range(min, max + 1);
guessText.text = guess.ToString();
}
}