Skip to content

Unity

Created: 2021-03-27 09:16:15 -0700 Modified: 2021-08-02 20:13:06 -0700

  • Using Visual Studio (reference): go to Edit → Preferences → External Tools → set the external script editor. After that, close Visual Studio and reopen it from Unity by double-clicking a script. You should get proper Intellisense then.
  • Make a prefab: just drag an object from the Hierarchy into the Project at the bottom.
  • Destroy a game object: in a script, “Destroy(this)” will destroy the script itself, so you want “Destroy(this.gameObject)” (or just “gameObject” for short).
  • Physics and layers: you can modify the layer of any GameObject at the upper right of the Inspector. Then, in Edit → Project Settings… → Physics or Physics2D → Layer Collision Matrix
  • Print something out: use print, Debug.Log, or Debug.LogFormat.
  • Ctrl+P: stop/play game
  • Applying physics to the particles (reference):
    • In the Inspector, check the Collision box, set the Type to World and change the mode if you’re in 2D.

Visual Studio Editor Package version 2.0.11 is available, we strongly encourage you to update from the Unity Package Manager for a better Visual Studio integration

Section titled Visual Studio Editor Package version 2.0.11 is available, we strongly encourage you to update from the Unity Package Manager for a better Visual Studio integration

Window → Package Manager → Type “Visual Studio Editor” → Click “Update”