
Learning C# by Developing Games with Unity 3D Beginner's Guide
By :

Create a List
that stores the names of some ponies. Since they are names, use the string
type.
Modify LearningScript
as shown in the next screenshot.
Notice the change on line 2.
Save the file.
In Unity, click on Play.
The following screenshot is the Console output. Notice the first output tells you there is a total of 3 elements in the List
:
Please notice that your code is using dot syntax, which will be discussed in more detail in the next chapter. The main concepts I want you to focus on here are the features of a List
.
The analysis of code is as follows:
The code on line 2 is as follows:
Using System.Collections.Generic;
To be able to use a List
, this tells Unity where to find the necessary C# code files for using a List
.
Change the using statement to using System.Collections.Generic;
.
The code on line 8 is as fololws:
List<string> myFavoritePonies = new List<string>();
This statement creates an empty L
ist
object.
First...
Change the font size
Change margin width
Change background colour