Objective: Basic understand what an array is and how to implement into code.
There are three ways to write an Array.
Declare the size (how many elements) through the inspector
the first method you need to save often, if Unity crashes you will loose the information you manually entered.
The second method is the same, if you change the size or the information contained you will loose said information if Unity crashed, unless you save after you edit the information.
specify in code what the values are
The third method is the safest from crashes because the information is hard coded in Unity. If Unity crashes the information will be filled in via the code.
If you wanted to print out an element you would use the Debug.Log
First fill out the elements with what ever you need.
Then use the debug.log with the number of the element you want.
If you wanted to randomize the element that is displayed you can use the random.range function.
Using arrays we can use call upon multiple elements, such as an inventory system or many other functions in your code. Don’t be afraid to experiment with your code, and I’ll see you in the next tutorial.