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 ...

Get Unity 4.x Game Development by Example Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.