Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

How to convert an inputfield's string to an int? (C#)

$
0
0
I'm trying to make an interactive random number generator, and I have two inputfields for the minimum and the maximum values. I know you can make a string to an int by doing int.Parse(variable), but if I do that Visual Studio gives me an error saying "Cannot implicitly convert type "int" to "UnityEngine.UI.Text". Below is my code if it helps. using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Controller : MonoBehaviour { public Text randomMin; public Text randomMax; private void Start() { randomMin = int.Parse(randomMin.text); randomMax = int.Parse(randomMax.text); } void updateMin (int Minimum) { randomMin = Minimum; } void updateMax (int Maximum) { randomMax = Maximum; } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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