hello …
i want to make the buttons higher or lower unclickable if the guess = max or 1000 in our case here or if the guess is equal to min or 1 so that only correct button remains clickable ?
i know this problem can be solved a number of ways and probably in easier ways than this but i guess this way is more fun and learning it can be useful for future situations as well
this is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class number : MonoBehaviour
{
[SerializeField] int max;
[SerializeField] int min ;
[SerializeField] TextMeshProUGUI guessText;
int guess;
// Start is called before the first frame update
void Start()
{
StartGame();
}
void StartGame()
{
NextGuess();
}
public void OnpressHigher ()
{
min = guess+1;
NextGuess();
}
public void OnpressLower ()
{
max = guess -1;
NextGuess();
}
void NextGuess()
{
guess = Random.Range(min, max);
guessText.text = guess.ToString();
}
}