C# Addendum
The C# version of the DisappearMe
script is nearly identical to the JavaScript version. There are just a few differences between the way in which JavaScript and C# scripts are set up.
using UnityEngine; using System.Collections; public class DisappearMeCSharp : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { renderer.enabled = false; } }
Notice that the C# script has two using
statements at the top. This is because there are thousands of collections of code and keywords that you can tap into with C#, and if we assume that every project needs to have access to every nook and cranny of the C# language, we'll wind up with a massive final file! The using
keyword tells Unity which specific sections of the C# language this script needs to access.
Another difference is the "class" declaration beneath the using
statements. Every C# script is its own class (like the Renderer
class we discussed earlier...