How to setup Unity 2017 and Visual Studio 2015 to use C# 6. (Step by Step)

Unity 2017 brought support for C# version 6. Unfortunately it doesn’t work out of the box with Visual Studio. Trying to google the problem I wasn’t able to find an all-in-one solution, but step by step I was able to work it out. This should work with a clean new project as well as with a previously created one.

The following is a step-by-step-guid to get things working. For the hasty ones: There is a summary of all steps at the end of this post. For the rest: I tryed my best to explain what we’re doing here. Don’t blame me if If my explanations are not 100% correct. I wouldn’t call myself an advanced user, if I didn’t have to for this to work. 😉

1. Get Unity to use DotNet 4.6

C# 6 is part of DotNet v.4.6. Unity by standart uses DotNet v.3.5. To change this, in Unity go to Edit => Project Settings => Player. Under Configuration change Scripting Runtime Version from Stable (.Net 3.5 Equivalent) to Experimental (.Net 4.6 Equivalent). Unity should now be ready to run C# 6 code.

2. Getting access to your project properties

Create a new C# script or choose an existing one and double click it to start Visual Stuio. (Im using VS 2015 v.3 but I think it should work in other versions too.) If you want to see how it doesn’t work yet, just insert some C# 6 exclusive code to a valid part of your script. For example:

int test {get;}

VS should mark this as erraneous, saying “Feature ‘readonly automatically implemented properties’ is not available in C# 4. Please use language version 6 or greater.” As you may have guessed, we also have to configure VS to use C# 6.

The C# version used is set in VS’ Project Properties. They are located under Project as the bottom menu item. (Instead of project the name of your project is used.) The problem is: If you klick it, the screen flashes and nothing happens. This is because Unity preconfigured the project for you and since you could potentially mess up your whole VS-Unity-pipeline playing with the project settings, the developers made it acessible only if you consider yourself an advanced user. So let’s tell VS that you are.

Navigate to Tools => Options. This should open up a window with a list of cathegories on the left. Choose Tools for Unity. Here under Miscellaneous (on the right side of the window) change Access to project properties to true, wich of course grants you said access to the project properties. Klick Ok to close the window.

3. Change project properties to use C# 6

Now try navigating to Project => Projec Properties again. This time a new tab should open up. On the left click Application if it is not highlightet. Here under Target framework choose .Net Framework 4.6. Visual Studio will tell you, that it wants to restart. Let it!

Next click Build on the lefthand list and finally proclaim yourself an advanced user by klicking the Advanced-button in the bottom right of the tab.

Another window should pop up, finally containing a setting for the utilized C# Language Version. Just change it from C# 4.0 to C# 6.0, click Ok and after a restart of VS everything should work fine.

 

Summary:

  1. In Unity:
    Edit => Project Settings => Player 

    change Scripting Runtime Version from Stable (.Net 3.5 Equivalent) to Experimental (.Net 4.6 Equivalent)
    Ok
  2. In Visual Studio:
    Tools => Options => Tools for Unity
    set Access to project properties to true
    Ok
  3. In Visual Studio:
    Project => Project Properties => Application
    as Target framework choose Net Framework 4.6.
    klick  Ok and agree to restart Visual Studio
    Project => Project Properties => Build => Advaned
    change Language Version to C# 6.0
    Ok
    restart Visual Studio

How to use DevkitPro with Code::Blocks ( + code-level-debugging)

Note: This tutorial is for Windows users. Still, chances are high, that you can abstract it for use on Linux.

I recently took some interest in Nintendo DS development. I tried several IDE’s but what worked best for me was Code::Blocks. It took some time to get everything right (including code-level-debugging with Insight and DeSmuMe) but in the end it worked out pretty well. When I started I didn’t know very much about configuring Code::Blocks, so when I got it done, I lived in constant fear, that I wouldn’t be able to get it done again. Then the day hit, when I decided to reinstall my OS. I knew I’d have to do set up everything from scratch afterwards. It was quite a bit of work and took me two days to get everything up and running again, but this time I took notes, so I wouldn’t have to live in fear again.

A big part of the solutions I use in this tutorial is based on another tutorial by a guy named “Niozero”.  It’s in spanish but google-translator does a pretty good job this time. You can find it here:

http://niozero.blogspot.de/2008/08/tutorial-codeblocks-devkitpro.html

TABLE OF CONTENTS:

1.   DOWNLOADING SOFTWARE

2.   INSTALLING SOFTWARE

3.   SETTING UP CODE::BLOCKS FOR DEVKITPRO

3.1    Setting up the compiler

3.2   Creating a template project

3.3   Save the template

4.  ADD “Run in Emulator” TO TOOLS

5.  CODE LEVEL DEBUGGING

1. DOWNLOADING SOFTWARE:

This step is easy! Just download the following files:

Code:Blocks IDE:

http://www.codeblocks.org/downloads

devkitPro Windows Installer/Updater:

http://devkitpro.org/wiki/Getting_Started

DeSmuMe 0.9.10 developer version with GDB stub activated:

http://bit.ly/DeSmuMeGDBstub

2. INSTALLING SOFTWARE:

Run the devkitPro-installer. If you choose not to install to “c:\devkitpro”, wich should be the standart-path, keep in mind that you’ll have to use your own path whenever in this document is refered to “c:\devkitpro”.

Run the Code::Blocks installer. Since the Code::Blocks-path is not used in this tutorial you can install it to wherever you want without having to be smart to use this tutorial.

Extract the DeSmuMe-archive to “c:\devkitpro\emulators”.

3. SETTING UP CODE::BLOCKS FOR DEVKITPRO:

WARNING: IF CODE::BLOCKS CRASHES WHILE YOUR SETTING IT UP, ALL YOUR CHANGES ARE LOST! HOPEFULLY IT WON’T CRASH, BUT TO PLAY SAVE I HIGHLY RECOMMEND YOU TO QUIT AND RESTART  CODE::BLOCKS AFTER EVERY FEW CONFIGURATIONS YOU MAKE. THIS WAY CRASHING WILL JUST TAKE YOU BACK TO THE LAST TIME YOU RESTARTED.

I use Code::Blocks 12.11 for this tutorial. Other (espescially newer) versions will probably do the job, but some things might be found in other places.

3.1 Setting up the compiler:

  • Go to menu ‘settings -> compiler’.

  • Choose “GNU GCC COMPILER” from the drop down menu entitled

  • “Selected compiler”.

  • Click on “Copy” and enter “DevKitPro ARM Compiler” as a name. “OK”

  • A window reminding you to set toolchains will appear. “OK”

  • Click the “Toolchain executables” tab.

  • Set “Compiler’s installation directory” to: “c:\devkitPro\msys”.

  • Click the “Additional Paths” tab.

  • Click “add” and type in “c:\devkitPro\devkitARM\bin”. “OK”

  • Go back to the “Program Files” tab and fill in the following settings:

C compiler:                 arm-none-eabi-gcc.exe

c++ compier:                arm-none-eabi-c++.exe

linker for dynamic libs:    arm-none-eabi-c++.exe

linker for static libs:        arm-none-eabi-ar.exe

make program:                make.exe

Code::Blocks should now be able to use the devkitPro-ARM-compiler. Since some settings are also to be made to a project in order to compile to NDS-ROMS we will now create a template project so we can later easily kickstart into NDS-development.

3.2 Creating a template project:

  • Go to menu ‘file -> new -> project’.

  • Select “Empty project”. “Go”

  • If a welcome message appears click “Next”.

  • Choose “Project title” and “Folder to create project in”. It’s up to “Next”

  • Choose “DevKitPro ARM Compiler” as your compiler. (Or whatever you named it.)

  • You can check of “Create “Debug” configuration” as we won’t need it. “Finish”

  • Now copy all contents from “C:\devkitPro\examples\nds\hello_world” to your newly created project’s directory.

  • In codeblocks rightclick on your new project in the management sidebar (right under “workspace”).

  • Select “add files recursively” and navigate to your project’s directory. “OK”.

  • Press “Select All”. “OK”

  • You should now see two folders “Sources” and “Others” below your project in management sidebar.

  • Click the “+” left to Sources and again “+” left to the now visible “source” folder and doubleclick main.cpp.

You should now see the code to a simple “hello world” program. Try pressing the compile button (ctrl + f9). You should get an error stating that “nds.h” is missing. This happens because you didn’t specify in your project’s settings, where to find the libnds-library.

  • Go to menu ‘project -> properties’.

  • Check “This is a custom Makefile”.

  • Set “Execution directory” to “${PROJECT_DIR}”. “OK”

  • Go to menu ‘project -> build options’.

  • Make sure “DevKitPro ARM Compiler” is “Selected compiler”.

  • Click on the “”Make” commands” tab.

  • Set the following values:

Build project/target:     $make -f $makefile

Compile single file:        $make -f $makefile

Clean project/target:        $make -f $makefile clean

Ask if rebuild is needed:    $make -q -f $makefile clean

3.3 Save the template:

Delete the hello_world.pnproj and hello_world.prj files from your project folder.

The main.cpp file will be your starting point for every project you create from the template. You can change it to whatever you like. I’ve simplified mine to the following:

#include <nds.h>
#include <stdio.h>

int main(void)
{
while(1)
{

swiWaitForVBlank();
}
return 0;
}

When you’re done changing your file go to menu ‘file -> save project as template’ and name it “NDS ROM” or anything you find fitting.

4. ADD “Run in Emulator” TO TOOLS:

My emulator of choice is DeSmuMe and I’ll use that one in this tutorial. Mainly because I got it to communicate with the debugger “Insight” (part of the devkitPro-package). If you prefer another emulator like no$gba you should easily be able to adapt my settings to your choice, since it’s not very complicated.

  • Go to menu ‘tools-> configure tools’. “Add”

  • Set to the following values:

Name:                 Run in DeSmuMe (or whatever you use)

Executable:            C:\devkitPro\emulators\DeSmuME\DeSmuME_VS2008_dev+.exe (Name of the exe can differ with other versions.)

Parameters:            ${PROJECT_DIR}\${PROJECT_NAME}.nds

Working Directory:    ${PROJECT_DIR}

  • Check “Launch tool visible (without output redirection)”. “OK” “OK”

  • Go to menu ‘settings -> editor’.

  • Select “Keyboard shortcuts” in the left sidebar.

  • In the “Commands”-subwindow, click on the little “+” left to “Tools”.

  • Click on the now visible entry “Run in DeSmuMe”.

  • Click into the field below “new shortcut” and press what ever keys you want to use. (In my case ctrl+shift+F5). “Add” “OK”

5. CODE LEVEL DEBUGGING:

If you used another emulator than the GDB-stub-enabled DeSmuMe version you downloaded in step 1. you’ll have to download and extract it now. (Revisite steps 1 and 2.) This version of DeSmuMe is able to communicate

with Insight, our debugger of choice. Insight is part of the devkitPro-package and should be already installed in your devkitpro folder.

Note: I have a strong feeling, that it’s also possible to use the debugger that comes with Code::Blocks along with DeSmuMe, but I didn’t get it to work. If you do I would really like to learn about how you did it! – In the insight folder “C:\devkitPro\insight\bin” create a batch file. I called mine “forcodeblocks.bat”. (Just a .txt file renamed to .bat.)

  • Into the batch file put the following lines:

start C:\devkitPro\emulators\DeSmuME\DeSmuME_VS2008_dev+.exe –arm9gdb=20000 %1.nds
C:\devkitPro\insight\bin\arm-eabi-insight.exe %1.elf
exit

  • Now again go to ‘tools->configure tools’ and click “Add”.

  • Fill in the following:

Name:                    Debug in Insight

Executable:            C:\devkitPro\insight\bin\forcodeblocks.bat

Parameters:            ${PROJECT_NAME}

Working Directory:    ${PROJECT_DIR}

  • Again you can add a shortcut like we did with “Run in DeSmuMe”. (Step 4.) I chose “ctrl+shift+F4”.

  • If you don’t have the template project we created earlier open open it now (or start a new from template).

  • Go to the menu ‘tools -> Debug in Insight’ or press your shortcut.

Insight and DeSmuMe should open. Now we have to connect the two programs. Therefore we go to insight’s menu ‘run->connect to target’.

  • A new window should pop up.

  • Set “Target” to GDBserver/TCP

  • Set “Port” to 20000. Hostname can be left blank. “OK”

This has to be done only once. After you clicked on OK you should get the message “successfully connected”. If you want to change this settings later go to file->target settings.

You should now be able to use insight as your debugger and see the results live in DeSmuMe.

A problem that at least occurs on my machine is, that I am unable to set breakpoints by mouse clicking. Fortunately there is a  workaround. Just enable the insight console by pressing ctrl+n and enter “b x” (where is x is the line you want to break at). Voila: There’s your breakpoint.

Note, that you must set your breakpoints after you connected to DeSmuMe. If you set them before, they will be ignored.

Now after you set your first breakpoint press C. Your ROM should start in DeSmuMe and runs until the breakpoint is reached. At that point you’re thrown back into insight, exactly at the line you wanted to break. You can now step through the program as you want with DeSmuMe updating for every step.

Most of my old solo-songs for you to download!

I decided to clean out my closet and release most of the musical solo-tracks I made in the past ten years. These tracks werte lying on my hd way too long so it’s twice-overdue to make them public. Most of this tracks have been posted on the net somewere before; mainly on my old myspace-page or on mp3.de.

1. Graf Porno – Fleisch

Download (mp3 in zip):

http://bit.ly/gp-fl

This is my first and only true solo-album from 2002. At that time my band FlsnE had kind of broken up (to be rejoined in late 2002) and I used the gap to work on some solo-songs. This was long before I even thougt aboubt becoming an audio engineer so the sound is charming at the utmost.  Nevertheless I feel some of the songs are quite nice. Most of the lyrics are in German so the album is possibly not of very much interest to non German folks.

2. Roi de Janeiro – Gesammeltes Schätzungsweise 2002 – 2008

Download (mp3 in zip):

http://bit.ly/rdj-doch

A collection of ten songs I made over the years, for what shold have become the second Graf-Porno-album. Later I changed my name to Roi de Janeiro and most of the tracks were made under latter name, wich is why i choose to use it for the whole collection. Audio-quality still differs between songs but is overally good enough to be enjoyable. Again most lyrics are German.

3. Roi de Janeiro – Remixes

Download (mp3 in zip):

http://bit.ly/rdj-rmx

Three remixes I made for online-contests (“Die Fantastischen Vier – Einfach sein”, “Digitalism – Going Home”, “Depeche Mode – Peace”) and one for befriended rap-grop ZHP (Party Tanzen Breakdance)

First Bjay New Are Enas map goes beta

I spent the last few weeks building the first map of what hopefully will grow into a series of dukematch maps for eduke32. The map is designed to be used with the high resolution pack wich can be found here. In addition to this you will only need the DUKE3D.GRP file from your Duke3D-CD. (Or wherever you got it.) It makes heavy usage of “true room over room” (TROR) wich is a hell of a cool thing when you come from traditional “build”. Aditionally I used many of my own handmade textures to give the map a unique feeling.  You can download the first beta of the map here:  BJAY NEW ARE ENAS v.09

Feel free to download the map. Just extract the archive to your eduke32 folder and choose “BNAE_v_0.9” as your custom directory. Unfortunately multiplayer ist broken in eduke32 at this very moment. But you can still check it out in singelplayer.

And now for some screenshots:

Image

Image

Image

Image

Image

Image