Our first script
Here, we will take our first steps into Visual Studio's code editing capabilities. As previously explained, this will be a very simple script with some, but with very little, explanation.
Now, double-click on the grayed-out RectAnim
script to open Visual Studio:
Once it is loaded, your screen should look comparable to this:
You should see the RectAnim.cs
filename highlighted in the left-upper corner. When a developer writes code, this is where we do it. Currently, you will see a couple of namespace declarations, the class name, and a few functions.
The Start()
function is called when an object is first instantiated; it is one of the first things that happens. So, it is the setup for a scripted object in Unity.
The Update()
function is called for every frame. When you need something to change on a regular basis, it is normally done through Update.
Now, replace all the code in RectAnim.cs
with the following code:
using System.Collections; using System.Collections.Generic; using UnityEngine...