July 3 - The Tank

Finishing up the Cartesian/location module in my Udemy course, I have just a few more tweaks to make to the code to finish off this project.

Lessons learned today:

  • input validation in the Unity GUI can be performed in the input box UI widget (via the Unity Editor interface), or alternatively, you can do “TryParse()” static function on a string to see if it can be converted to “int”, say.
int n;
        if (int.TryParse(amt, out n))
        {
            energyAmount = energyAmountText.GetComponent<Text>();
            energyAmount.text = amt;
        }
		//if this is true, then set energyAmount.text to the entered value amt.
  • there is a feature in the Unity loop called “Awake”, which happens on initialization of the program before the Start function runs. I will need to look into the loop a bit further but I know it is posted on the Unity site. https://docs.unity3d.com/Manual/ExecutionOrder.html

DCDE - The Tank