Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Is there a way to combine 2 methods?

$
0
0
I'm just trying to get acquainted with how buttons control text objects. Could my two methods (counterUp and counterDown) be combined into one method that responds to both the number up and number down buttons in Unity? (For the sake of only manage one method instead of 2). to If so how? public class MainScript : MonoBehaviour { int count; public Text numberUpDown; void Start () { StartGame (); } void StartGame() { count = 100; } public void counterUp () { count = count+1; numberUpDown.text = count.ToString (); } public void counterDown () { count = count-1; numberUpDown.text = count.ToString (); } }

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>