Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Installing Visual Studio Community for Unity Development

A good Integrated Development Environment (IDE) is necessary to write good Code. At least, in the beginning, it is. Visual Studio is one such development environment. It’s the gold standard for such programs.

An IDE contains everything you need, and more, for writing code. It provides syntax highlighting and lets you know if you made any errors. IDE features built-in documentation built right into the editor, making it easy to look things up. It features tools to diagnose issues, aka bugs, as well as an assortment of tools to make writing code easier.

While you don’t need an IDE to write code, you’ll find that once you become used to them, you’ll never want to write code without one. In the previous article, you installed Unity. In this one, you’ll get your code editor installed.

Choosing your code editor

Visual Studio is the preferred IDE for Unity, but that was not always the case. In the old days, Unity shipped for Mac with an IDE called MonoDevelop. While it worked well enough (I’ve written games in it after all), it was not a pleasant editor. Code writing sessions often felt like wrestling matches.

MonoDevelop was a painful editor back in the day

At some point, Microsoft released a version of Visual Studio for the Mac called Visual Studio Code. While I was skeptical at first, this simple editor has become my “go-to” editor of choice for all development tasks on a Mac. It’s just that good.

Soon after, it didn’t take long for Microsoft to port Visual Studio to the Mac. Now, Visual Studio Community (the free version) is the recommended code editor for Unity for both Windows and Mac.

If you’ve taken my YouTube course on Unity, you will have been using Visual Studio Code. This was a mistake as it requires a bunch of extra steps, causing issues with students. It also doesn’t support live debugging in Unity which is an essential tool.

Visual Studio Code is one of the best most versatile code editors that I’ve used. You can write anything in it and it supports Windows, Mac, and Linux

In the following sections, I’ll describe how to install Visual Studio Community for both Mac and Windows. Should you have issues, please leave a comment, or leave a message in the Forums. Mind you, I’ll do my best to help you but I’m not a dedicated support technician. If your problem is beyond my knowledge, I’ll recommend you to official support.

Visual Studio versions

Like Unity, Visual Studio is not free software. In fact, back in the day, it could be an easy two thousand dollars to get a stripped-down version of the suite. These days, you can get Visual Studio for free, but ultimately, Microsoft wants you to be a paying customer.

Visual Studio Community is the free version. It’s meant for open-source development and education. Once you reach a revenue spike of over a million dollars and your company exceeds five people, you must use Visual Studio Professional. Like Unity, you pay once you start achieving some sort of revenue threshold.

Visual Studio Professional gives you the base editor but all the bells and whistles. You also gain access to a few services. Being the year 2023, this editor is now subscription based so you are looking to pay forty dollars per month.

Visual Studio Enterprise gives you everything you could possibly need to develop software. This is the highest tier so naturally, it sports the highest price. This costs a cool two hundred and fifty per month.

If you are curious about all the different versions and the features between them, you can read more on Visual Studio’s comparison page. This series of articles will be using Visual Studio Community.

Note: Since I wrote this article, Microsoft officially announced that Visual Studio Community for macOS will be retired in 2024. You should use Visual Studio Code instead. I will be producing an article on this soon.

Installing Visual Studio on macOS

To install Visual Studio Community on a Mac, head over to the following link: https://visualstudio.microsoft.com/downloads/

Skip over the editions, and scroll down the page until you see a listing for Visual Studio on a Mac. This may have changed by the time you are reading this.

Make sure to click the Free download button. This will prompt you to download a dmg file. Download and run the file. When the installer opens, you’ll be presented with some installation options. Keep the default items selected and click the Install and Update button.

It’s going to take a little time to install. Sit back. Put your feet up. Have a cold iced tea! :D Keep in mind, you will be prompted to enter your password one or two times.

When the application finishes launching, you’ll be presented with a project launch window. All your various projects will show up in that window.

Believe it or not – that’s it! The application uses a special extension for Unity support. To verify the extension installation, click Visual Studio / Extensions.

This will open an Extensions window. Click the Installed tab and check to see Visual Studio for Mac Tools for Unity is in the list.

If for some reason, you don’t see it listed, then click on the Browse tab and search the listings. Select it and click the Install button. And that’s it! You have Visual Studio installed on the Mac!

Installing Visual Studio on Windows

To install Visual Studio Community on a Mac, head over to the following link: https://visualstudio.microsoft.com/downloads

You’ll see a whole bunch of options. Click the download link for the Community edition.

Download the file and run the installer.

It will take the installer a little time to complete as it downloads all of the components. Once complete, do not press the Launch button. Press the Modify button, instead.

This new dialog allows you to customize your installation. You can install special workloads, language packs, and install individual components. The Workloads tab is selected by default.

Scroll down until you see a Gaming category. It should contain an item called, “Game Development with Unity”. It should come installed with Unity. If it is not checked, check the item and click the install button. Now you can launch the editor.

In the case, you launched the application instead of checking for the Unity tools, you’ll be presented with a project window. All your code projects will appear in this window. Since you haven’t written any code yet, the window is empty.

Press the Continue without code option. This opens a blank editor. Select the Tools menu option. From the dropdown, click the Get Tools and Features option.

This will open the installer and present the Workloads tab. From there, you can scroll down and find the Unity tools as described earlier in the article.

Installing Unity on Linux

Believe it or not, you can actually use Unity on Linux. The process requires some understanding of the terminal. Also, being that Visual Studio Community, you’ll need to either use Visual Studio Code or use a native Linux code editor. Of course, you could try to run the application under something like Wine but you may run into lots of issues. Personally, I would use something like Visual Studio Code or JetBrains Rider.

Unity does provide instructions on how to install Unity for distributions such as Debian (and Ubuntu) as well as Red Hat (and CentOS). If you are using a different distribution then you’ll probably need to do some additional configuring to get Unity to work. Chances are, someone has already produced a guide on it.

You can find instructions on how to install Unity Hub for Linux on Unity’s official site. Also, make sure to check out the Linux support forum in case you have any issues. Unity Technical Support seems pretty active on it.

Testing your installation

Okay, you’ve read this article and you have a working code editor. It’s time to put it to us. To test this, you’ll create a very simple project.

Launch Unity Hub. In the upper right-hand corner, click the New project button.

This brings you to the project template selection dialog. By default, Unity games were 3D and looked quite ugly. It took a lot of work to configure the editor for your workflow. Now we have templates that do all that work for you.

In your project, you will be playing with code so the 3D Core project is fine. Select the 3D Core project. For the project name, give the name: Beginning C Sharp. Feel free to choose your save location. Then click the Create project button.

Creating a project opens the Unity editor. There are a lot of buttons and the whole thing can seem a bit overwhelming. First, you need to configure the code editor.

If you are on a Mac, select Unity \ Settings. If you are on Windows, select Edit \ Preferences. This opens your preferences window. Select the External Tools option. Then, from the External Script Editor option, select Visual Studio from the dropdown. Close the window.

Now to write a small bit of code. In Unity, at the center bottom of the screen, you’ll see a tab called Project. It should look like the following:

If your window looks different, then click the dropdown in the upper right hand corner. It should be next to the drop-down that reads Layers. Select the Default options.

To create your first script, click the Plus button underneath the Project tab.

You’re going to see a ton of options. Since this is an article series about writing C#, choose the C# Script. It should be the second option.

Once you select the option, Unity will add the script in your Projects tab. Give it the name, HelloWorld. Name it exactly as printed here. Notice there are no spaces and the H and W are capitalized.

Now for the moment, you’ve been waiting for! Double-click on the HelloWorld script. This will open Visual Studio. Now to write your first line code!

Writing some code

When Visual Studio launches, you should see something like this.

If you’ve never typed code before, this is overwhelming. Each line has its purpose, but don’t worry about learning what everything is doing. You will in time. Instead, focus on what you are doing.

Now, underneath the code void Start() between the curly braces, type: Debug.

Make sure to include the period after the word Debug. It should exactly match the code below:

void Start()
{
  Debug.
}

Whenever you type code, always write it exactly as you see it. Case matters along with weirdly placed punctuation marks. Now, once you press the period, you should see a whole bunch of options. That lets you know that your editor is working with Unity.

Finish the code with the following, making sure to match the code listed below:

void Start()
{
  Debug.Log("Hello World");
}

Notice the line ends with a semi-colon. A semi-colon is the ending of a single statement of code. Think of it like a period at the end of a sentence. What does Debug mean? How about Log? Who cares! You wrote a line of code.

If you typed it wrong, you might see some red squiggles like the following:

In the example, I forgot to add a close quotation mark. The red squiggles indicate an error. If you see a red squiggle, compare your code with the article again. Chances are, you lowercased a letter when it should have been uppercased. Your code should look exactly as this:

Save and switch back to Unity.

Now, drag your HelloWorld script to the upper left-hand side of the screen. Drop it on the Main Camera.

Finally, in the top center of the screen, press the play button. This will start the game. Granted, it’s not a game, but it will run your code.

Down by your Project tab, you’ll see another tab called Console. The Console is a way to print messages to the screen for testing and logging purposes. Users will not see them.

Click the tab and you’ll see Hello World printed.

If for some reason you don’t see the Console, select Window \ General \ Console and it will appear. Nice work!

Where to go from here

Congratulations! You wrote your first bit of code! Granted, it didn’t do much besides printing out text to the console. And of course, the text was only visible to you. Ideally, you want to the article to appear in the game world.

You’ll do this in time, but before you can do anything, you need to get orientated to Unity itself. The next article will give you a tour of the interface. You’ll be writing code soon enough!

The post Installing Visual Studio Community for Unity Development appeared first on Jezner Blog.



This post first appeared on Jezner - Old Time Radio, please read the originial post: here

Share the post

Installing Visual Studio Community for Unity Development

×

Subscribe to Jezner - Old Time Radio

Get updates delivered right to your inbox!

Thank you for your subscription

×