Skip to content

Instantly share code, notes, and snippets.

@MeowKim
Last active June 5, 2020 07:20
Show Gist options
  • Save MeowKim/0206fe686de0c345a1cb6ca867a3217b to your computer and use it in GitHub Desktop.
Save MeowKim/0206fe686de0c345a1cb6ca867a3217b to your computer and use it in GitHub Desktop.
Simple setup guide for Unity Development with VSCode.

Table of contents

About

Simple setup guide for Unity Development with VS Code.

This guide Supports languages below.

Created: 2020-06-04
Last updated: 2020-06-05

Unity3D

Install & run Unity Hub

https://unity3d.com/get-unity/download

Login

Go to Profile > Sign in on the top-right.

Activate license

Go to Profile > Manage license on the top-right.
Click ACTIVATE NEW LICENSE.

  • Choose License Agreement: Unity Personal
  • Choose I don't use Unity in a professional capacity.
  • Click DONE.

Install Unity3D

Go to Installs on the left.
Click ADD.

  • Choose version of Unity: Unity 2019.3.15f1
  • Click NEXT.

Create & run new project

Go to Projects on the left.
Click NEW.

  • Leave options as default.
  • Click CREATE.

Setup VSCode as Unity Script Editor

Go to Edit > Preferences.

  • Click External Tools on the left.
  • Choose Exteral Script Editor: Visual Studio Code.

Install & setup VSCode extension asset

Go to Asset Store and search the keyword as VSCode.

  • Download & Import this.

Go to Edit > Preferneces.

  • Click VSCode on the left.
  • Edit VS Code Path: C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd
  • Enable all options listed below.
    • Enable Integration
    • Use Unity Debugger
    • Revert Script On Unl..
    • Output Messages To Console
    • Always Write Lauch File

✨Dark theme

(Optional) If you are interested in dark theme on Unity, see here.

VSCode

Prerequisites

Requires .NET Core SDK.
Check the stuff installed via dotnet command on CMD.

$ dotnet --version

If you have to install newly, restart Windows would be needed.

Install & run VSCode

https://code.visualstudio.com/Download

Install extensions for Unity

Go to View > Extensions.
Install extensions listed below.

Test

Create new script

[Unity]
Go to Assets > Create > C# Script.
Create with default name(NewBehaviourScript) & open it.

[VSCode]
Copy & paste code lines below to NewBehaviourScript.cs.

using  System.Collections;
using  System.Collections.Generic;
using  UnityEngine;

public  class  NewBehaviourScript : MonoBehaviour
{
	int test = 0;

	// Start is called before the first frame update
	void  Start()
	{
		Debug.Log("Start()");
	}

	// Update is called once per frame
	void  Update()
	{
		test++;
		Debug.Log("Update(): test = "+test);
	}
}

Add componet to GameObject

[Unity]
Choose SampleScene > Main Camera in Hierachy window.
Click Add Component and choose Scripts > New Behaviour Script in Inspector window.
Save. (shortcut: Ctrl+S)

Restart

Restart both Unity & VScode.

Start debugging

[VSCode]
Set a breakpoint on a line of Debug.Log("Update(): test = "+test);.
Go to Run > Start Debugging. (shortcut: F5)

[Unity]
Play the scene.

Check out

image

When the code at the breakpoint is executed, the debugger will stop.

Troubleshooting

Restart would resolve most of problems.
Good luck. 😉

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment