Fundamentals
With Visual Studio installed and connected to Unity’s editor, we should go over the basics. In this section, we will talk about data types, variables, logic or code flow, methods, classes, and MonoBehaviour
. There is a lot of knowledge in this section of the chapter, but it is meant to be referenced. If you have a sticky note, it might be a good idea to place it in this chapter to easily be referenced. When you open the file, there will be autopopulated C# that we will not need for this part. For now, delete the extra parts so that it looks like this:
using UnityEngine;
public class ScriptingLesson : MonoBehaviour
{
// Data and Variables
// Logic and Flow
// Methods
}
The code here is doing two primary tasks. The first line imports the UnityEngine
library so that we can use types and methods from the UnityEngine
namespace for our game. This is called the “using directive”. Inside the UnityEngine namespace, we have access to all of our game...