Hey guys, just wanted to share my Rick and Morty inspired Number Wizard UI with you all. I spent way too long on it!
https://sharemygame.com/@markymark9/nwui-mr-meeseeks
I noticed there’s a bug where clicking higher repeatedly will let you get to over 1000 (which is the current max defined in the inspector). It doesn’t really matter as I won’t be revisiting it, but thought it would be good practice to try and work out exactly why it’s happened. As far as I can tell, my code is identical to Rick’s.
using JetBrains.Annotations;
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;
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 + 1);
guessText.text = guess.ToString();
}
}