Tutorial  Updated

How to create Nintendo Switch games with Unity.

Note: NSPs build with a leaked SDK are not allowed to be shared on GBATemp (and most likely nowhere else too) because they were build with "stolen code". These NSPs can only be installed on hacked switches with sigpatches, so please only do projects for yourself instead of publishing them and making Nintendo mad & possibly even sue you.




Foreword:
If you are some random kid that wants to make a game for the switch without knowledge about Unity, Switch development and C/C++, stop right here. This is not meant for you and if you want to make a game that runs on the switch, use Godot. It is easy to make games with and they are legal to share. Dont expect any kind of help for making "illegal games", especially not if you cant read error messages to figure things out on your own.



Prerequisites
  • A leaked (or official) Nintendo Switch SDK from Nintendo (for example NX SDK 15.3.0) *
  • The corresponding Unity version (for example 2023.1.0b2)
  • The corresponding Unity "support for editor" addon. **
  • https://github.com/The-4n/hacPack on your harddrive and added to your PATH environment variable

* I will not provide links to any SDK, nor will i tell you where to find it. Don't even ask.
** These links, while not publicly shared, are not protected in any way by unity. If you have the link from their website, you can download them without any restriction. However i still wont provide any URLs.

The leaked SDKs that you can find online usually do not have the same folder structure. They are often incomplete, scrambled or in other ways messed up which makes it hard to write a unified guide for them. I will therefore base this guide on a 15.3.0 SDK that recently leaked. Your experience might be different and its a lot of trial and error to get it working.


Folder structure of the recently leaked SDK:
1675693698611.png




"Installing" the SDK

The complete SDK consists of many "addons" and most (if not all) of them are needed to make the build process work. You basically want to go through all folders and check if they have either a "NintendoSDK", "NintendoSDK-NEX", "NintendoSDK-NPLN" or "NintendoSDK-Pia6" subfolder and then merge them on your harddrive. Usually you will not overwrite any files except for maybe a license file. If you do this, you basically have a complete SDK with all addons installed to it. This is how it should look like on your harddrive once you are done (- the combined size is about 24GB.):
1675694161728.png



After you have extracted the necessary data, its time to add some environment variables. The folder path changes depending on where you put the SDK files obviously.
Restart your PC for them to take effect.
1675694314291.png





Installing Unity + Addon

Now you can install Unity and its "support for editor" addon. Make sure to install the correct version of both Unity and the addon, since the SDK is made for these specifically. You might get away with some versions lower and higher but there is absolutly no guarantee. Its best if you don't mix and match but choose the correct one. Usually the addon is delivered with the leaked SDK itself, which also tells you what Unity version to use.





Creating a game (or whatever)

It is highly advised that you read the documentation that comes with the SDK!

Stuff like character controller / HID and what not are all explained in the documentation. READ IT.

Once you are happy with your game (or whatever), click "File -> Build Settings" and change the Platform to Nintendo Switch. Let everything load, check the "Create NSP ROM File" checkbox and adjust all the NMETA settings in the "Player Settings" menu. I wont go over that stuff as its a lot and i am sure you can read and figure it out on your own. Click "Build" to create an NSP.

1675695144004.png






Making it installable

If you did everything correctly, you should now have an NSP file. But lets be honest, you do not own a dev unit to install the NSP on, do you?
Well, to be able to install and play your game on a retail switch, you need to repack it with your own retail unit keys. Use lockpick_rcm to get them and place them in (create if the folder does not exist):
Code:
C:\Users\<YOUR USER NAME>\.switch

You can then use hactool or any other method of your liking to repack the NSP. I created a simple repacker (check attachments) that does the job for me, however i wont guarantee that it works for you too. Either double-click the files or simply drag an NSP onto them. Its python code converted to an EXE so it might trigger your AV. You don't have to use it if you don't trust it but repacking research has to be done by you then.

Make sure that hacpack is on your harddrive and added to your PATH envoronment variable.
1675696284973.png


To use my repacker, the NSP needs to have its titleID somewhere inside the filename. You can check the titleID in Unity under "Player Settings -> Publishing Settings" as "Application ID" (the 0x is NOT part of the titleID). So you can rename your NSP to something like "mygame_01004b9000490000.nsp or whatever you like, then simply drag the NSP on repacker.exe.

Once you have a repacked NSP, you can install it to a retail unit running Atmosphere with sigpatches.
Have fun creating some games!





Result

The result could look like this:


2023020616251200-57B4628D2267231D57E0FC1078C0596D.jpg
PXL_20230111_050837650.jpg
 

Attachments

  • repack.7z
    5.9 MB · Views: 98
Last edited by Slluxx,

PeaceHacker

Member
Newcomer
Joined
Jan 24, 2021
Messages
16
Trophies
0
XP
139
Country
United States
Note: NSPs build with a leaked SDK are not allowed to be shared on GBATemp (and most likely nowhere else too) because they were build with "stolen code". These NSPs can only be installed on hacked switches with sigpatches, so please only do projects for yourself instead of publishing them and making Nintendo mad & possibly even sue you.

Prerequisites
  • A leaked (or official) Nintendo Switch SDK from Nintendo (for example NX SDK 15.3.0) *
  • The corresponding Unity version (for example 2023.1.0b2)
  • The corresponding Unity "support for editor" addon. **
  • https://github.com/The-4n/hacPack on your harddrive and added to your PATH environment variable

* I will not provide links to any SDK, nor will i tell you where to find it. Don't even ask.
** These links, while not publicly shared, are not protected in any way by unity. If you have the link from their website, you can download them without any restriction. However i still wont provide any URLs.

The leaked SDKs that you can find online usually do not have the same folder structure. They are often incomplete, scrambled or in other ways messed up which makes it hard to write a unified guide for them. I will therefore base this guide on a 15.3.0 SDK that recently leaked. Your experience might be different and its a lot of trial and error to get it working.


Folder structure of the recently leaked SDK:
View attachment 351543




"Installing" the SDK

The complete SDK consists of many "addons" and most (if not all) of them are needed to make the build process work. You basically want to go through all folders and check if they have either a "NintendoSDK", "NintendoSDK-NEX", "NintendoSDK-NPLN" or "NintendoSDK-Pia6" subfolder and then merge them on your harddrive. Usually you will not overwrite any files except for maybe a license file. If you do this, you basically have a complete SDK with all addons installed to it. This is how it should look like on your harddrive once you are done (- the combined size is about 24GB.):
View attachment 351544


After you have extracted the necessary data, its time to add some environment variables. The folder path changes depending on where you put the SDK files obviously.
Restart your PC for them to take effect.
View attachment 351545




Installing Unity + Addon

Now you can install Unity and its "support for editor" addon. Make sure to install the correct version of both Unity and the addon, since the SDK is made for these specifically. You might get away with some versions lower and higher but there is absolutly no guarantee. Its best if you don't mix and match but choose the correct one. Usually the addon is delivered with the leaked SDK itself, which also tells you what Unity version to use.





Creating a game (or whatever)

It is highly advised that you read the documentation that comes with the SDK!

Stuff like character controller / HID and what not are all explained in the documentation. READ IT.

Once you are happy with your game (or whatever), click "File -> Build Settings" and change the Platform to Nintendo Switch. Let everything load, check the "Create NSP ROM File" checkbox and adjust all the NMETA settings in the "Player Settings" menu. I wont go over that stuff as its a lot and i am sure you can read and figure it out on your own. Click "Build" to create an NSP.

View attachment 351547





Making it installable

If you did everything correctly, you should now have an NSP file. But lets be honest, you do not own a dev unit to install the NSP on, do you?
Well, to be able to install and play your game on a retail switch, you need to repack it with your own retail unit keys. Use lockpick_rcm to get them and place them in (create if the folder does not exist):
Code:
C:\Users\<YOUR USER NAME>\.switch

You can then use hactool or any other method of your liking to repack the NSP. I created a simple repacker (check attachments) that does the job for me, however i wont guarantee that it works for you too. Either double-click the files or simply drag an NSP onto them. Its python code converted to an EXE so it might trigger your AV. You don't have to use it if you don't trust it but repacking research has to be done by you then.

Make sure that hacpack is on your harddrive and added to your PATH envoronment variable.


To use my repacker, the NSP needs to have its titleID somewhere inside the filename. You can check the titleID in Unity under "Player Settings -> Publishing Settings" as "Application ID" (the 0x is NOT part of the titleID). So you can rename your NSP to something like "mygame_01004b9000490000.nsp or whatever you like, then simply drag the NSP on repacker.exe.

Once you have a repacked NSP, you can install it to a retail unit running Atmosphere with sigpatches.
Have fun creating some games!





Result

The result could look like this:


View attachment 351573View attachment 351574
I am having issues trying to get the software I compiled to have working controller inputs from both the joycons and pro controller but it does not seem to do anything every time I press the corresponding button in the game to do an action, the game does not recognize controller inputs??????
 

ih8god

Member
Newcomer
Joined
Mar 9, 2021
Messages
10
Trophies
0
Age
41
XP
65
Country
Canada
I am having issues trying to get the software I compiled to have working controller inputs from both the joycons and pro controller but it does not seem to do anything every time I press the corresponding button in the game to do an action, the game does not recognize controller inputs??????
Initialize the appropriate plugin on startup. There are packages you can install for using the new input manager system along with native calls to your project that can be helpful. Look within the HID and Npad area.

OP wasn't kidding by recommending a solid read through of the docs.
 
  • Like
Reactions: Slluxx

PeaceHacker

Member
Newcomer
Joined
Jan 24, 2021
Messages
16
Trophies
0
XP
139
Country
United States
Initialize the appropriate plugin on startup. There are packages you can install for using the new input manager system along with native calls to your project that can be helpful. Look within the HID and Npad area.

OP wasn't kidding by recommending a solid read through of the docs.
Code:
ArgumentException: Input Button joystick button 0 is not setup.
 To change the input settings use: Edit -> Settings -> Input
UnityEngine.Input.GetButton (System.String buttonName) (at <d5feade26b024b908b8bca84e4cc17c7>:0)
InputManager.get_HoldArray () (at Assets/Scripts/Gameplay/Input.cs:29)
StrumsController.Update () (at Assets/Scripts/Gameplay/StrumsController.cs:32)
trying to do anything regarding that gives this error, and I am pretty stuck since the docs don't talk about this to my knowledge

you also have to keep in mind I am a complete beginner to unity and anything like this so it's hard to just make anything with it
 

ih8god

Member
Newcomer
Joined
Mar 9, 2021
Messages
10
Trophies
0
Age
41
XP
65
Country
Canada
Code:
ArgumentException: Input Button joystick button 0 is not setup.
 To change the input settings use: Edit -> Settings -> Input
UnityEngine.Input.GetButton (System.String buttonName) (at <d5feade26b024b908b8bca84e4cc17c7>:0)
InputManager.get_HoldArray () (at Assets/Scripts/Gameplay/Input.cs:29)
StrumsController.Update () (at Assets/Scripts/Gameplay/StrumsController.cs:32)
trying to do anything regarding that gives this error, and I am pretty stuck since the docs don't talk about this to my knowledge

you also have to keep in mind I am a complete beginner to unity and anything like this so it's hard to just make anything with it
I don't actually use either of Unity's inputs. There is a SinglePlayerController script. I used that as a starter and added what I needed. Then use the Npad class.
Post automatically merged:

Code:
ArgumentException: Input Button joystick button 0 is not setup.
 To change the input settings use: Edit -> Settings -> Input
UnityEngine.Input.GetButton (System.String buttonName) (at <d5feade26b024b908b8bca84e4cc17c7>:0)
InputManager.get_HoldArray () (at Assets/Scripts/Gameplay/Input.cs:29)
StrumsController.Update () (at Assets/Scripts/Gameplay/StrumsController.cs:32)
trying to do anything regarding that gives this error, and I am pretty stuck since the docs don't talk about this to my knowledge

you also have to keep in mind I am a complete beginner to unity and anything like this so it's hard to just make anything with it
Sorry, I think the script I used is actually called HidSinglePlayer that I started with.
 
Last edited by ih8god,

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
Code:
ArgumentException: Input Button joystick button 0 is not setup.
 To change the input settings use: Edit -> Settings -> Input
UnityEngine.Input.GetButton (System.String buttonName) (at <d5feade26b024b908b8bca84e4cc17c7>:0)
InputManager.get_HoldArray () (at Assets/Scripts/Gameplay/Input.cs:29)
StrumsController.Update () (at Assets/Scripts/Gameplay/StrumsController.cs:32)
trying to do anything regarding that gives this error, and I am pretty stuck since the docs don't talk about this to my knowledge

you also have to keep in mind I am a complete beginner to unity and anything like this so it's hard to just make anything with it
the error message says it all:

ArgumentException: Input Button joystick button 0 is not setup.
To change the input settings use: Edit -> Settings -> Input

You need to set up your controls in unity. Map the new input system to the jocons. Watch a tutorial about it on youtube - this has nothing to do with building the application.

That said, you have so many problems with this that you cant solve on your own which make me question if you should even do this at all. You can't distribute a game like this and you gain nothing from it. Better look at https://github.com/Stary2001/godot and make a game this way. Its much easier, legal and has a lower barrier of knowledge.
 

ih8god

Member
Newcomer
Joined
Mar 9, 2021
Messages
10
Trophies
0
Age
41
XP
65
Country
Canada
the error message says it all:



You need to set up your controls in unity. Map the new input system to the jocons. Watch a tutorial about it on youtube - this has nothing to do with building the application.

That said, you have so many problems with this that you cant solve on your own which make me question if you should even do this at all. You can't distribute a game like this and you gain nothing from it. Better look at https://github.com/Stary2001/godot and make a game this way. Its much easier, legal and has a lower barrier of knowledge.
I'm in the middle of a Switch project currently and I only used the old input system for UI menus I think. The whole integration just feels really disconnected or something. Compared to PS4, Vita and Xbox at least. Input systems are one of the areas I find most difficult myself so can really relate. I'm also the furthest from an expert as well haha.
 

notChocoMilk

Member
Newcomer
Joined
Nov 5, 2023
Messages
11
Trophies
0
XP
19
Country
United States
i have setup the nintendo switch sdks properly & can compile nsp files just fine, but for some odd reason, the icon specified in unity never appears on the switch, and is instead replaced by a placeholder "NintendoSDK Application" icon..
1708162876933.png
 

Attachments

  • 2024021703375300-57B4628D2267231D57E0FC1078C0596D[1].jpg
    2024021703375300-57B4628D2267231D57E0FC1078C0596D[1].jpg
    296.5 KB · Views: 22

PeaceHacker

Member
Newcomer
Joined
Jan 24, 2021
Messages
16
Trophies
0
XP
139
Country
United States
i have setup the nintendo switch sdks properly & can compile nsp files just fine, but for some odd reason, the icon specified in unity never appears on the switch, and is instead replaced by a placeholder "NintendoSDK Application" icon..View attachment 420511
There are two spots where you have to add the application icon; that is one of them. I think it has to be a 24-bit BMP with a max recommended of 1024x1024
The second place you have to add one is under the "Publishing Settings" tab under build settings in player settings, and under the "Language Settings" Tab is where you then have to select the game's supported regions/languages; my preference is that I just click American English. Enter your application title, Name, Publisher Name, etc, then click the icon and add it as you would with a normal texture.

1708381937262.png


If this still does not work for you, or you get build errors when adding an icon here, then try making your application and using the AuthoringEditor exe app in the NintendoSDK/Tools folder and use that to open up your NSP to add that information then there. But remember that using this secondary method will require you to do this every time you build your application.
Post automatically merged:
 
Last edited by PeaceHacker,

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
Input mapping typically does not work in unity and is very finicky
I managed to get it working just fine with the new system. Yes, its finnicky but it works if you spend some time figuring it out.

I also find that using the application you provided is a good alternative but very restrictive in its capabilities.
Sorry what? The only application i provide is a repacker for the keys. I dont know how that would be either a "good alternative" nor "very restrictive in its capabilities". If you used the wrong word here and meant the entire writeup then "I do not see the usage I could get out of it over Unity" does not make much sense.

No regular person is meant to do any gamedevelopment in unity (for the switch using this sdk) whatsoever. You are not allowed to distribute them anyway, which i make very clear in my first post. If you have no experience developing anything in unity or for the switch in general - you are not the person this is aimed for.

I am just using this to learn Unity in a more limited environment than on a PC

Sorry but that doesnt make sense either because it simply does not exist. Unity development is the same for pc and for switch. The only real difference is the build process and button mapping or if you want to use system features like rumble or IR, for which you need c++ knowledge anyway. The core game development is exactly the same.


Basic rule of thumb (for everyone, not just you):
If you never developed anything in unity, this is not for you.
If you never developed any homebrew for the switch, this is not for you.
If you have no expercience in c/c++, this is most likely not for you.
If you "just want to make a game", this is not for you.


Everyone with no experience in this field should stick to Godot. Its easy to create games and its legal to distribute them.
 

ih8god

Member
Newcomer
Joined
Mar 9, 2021
Messages
10
Trophies
0
Age
41
XP
65
Country
Canada
I managed to get it working just fine with the new system. Yes, its finnicky but it works if you spend some time figuring it out.


Sorry what? The only application i provide is a repacker for the keys. I dont know how that would be either a "good alternative" nor "very restrictive in its capabilities". If you used the wrong word here and meant the entire writeup then "I do not see the usage I could get out of it over Unity" does not make much sense.

No regular person is meant to do any gamedevelopment in unity (for the switch using this sdk) whatsoever. You are not allowed to distribute them anyway, which i make very clear in my first post. If you have no experience developing anything in unity or for the switch in general - you are not the person this is aimed for.



Sorry but that doesnt make sense either because it simply does not exist. Unity development is the same for pc and for switch. The only real difference is the build process and button mapping or if you want to use system features like rumble or IR, for which you need c++ knowledge anyway. The core game development is exactly the same.


Basic rule of thumb (for everyone, not just you):
If you never developed anything in unity, this is not for you.
If you never developed any homebrew for the switch, this is not for you.
If you have no expercience in c/c++, this is most likely not for you.
If you "just want to make a game", this is not for you.


Everyone with no experience in this field should stick to Godot. Its easy to create games and its legal to distribute them.
I wouldn't say it's the same. NX uses C++ primarily and their integration with Unity is not like writing something for PC or PS4 where one has done everything in C#. Using the SDK was not nearly as smooth as PS4 or Vita. Also, newer versions of Unity are pretty trash. 2017 FTW
 

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
I wouldn't say it's the same. NX uses C++ primarily and their integration with Unity is not like writing something for PC or PS4 where one has done everything in C#. Using the SDK was not nearly as smooth as PS4 or Vita. Also, newer versions of Unity are pretty trash. 2017 FTW
[...] or if you want to use system features like rumble or IR, for which you need c++ knowledge

The pure gamedevelopment part, eg "using unity" is the same. There is no reason to learn that on the switch specifically. There is no reason to go with this very specific setup to learn unity or c++. If anything, i would say it makes your experience in learning either much much worse.
 

CompuGeniusPrograms

Member
Newcomer
Joined
Jun 2, 2022
Messages
13
Trophies
0
Location
New York
Website
www.cgprograms.com
XP
71
Country
United States
I was able to build and run a game on my switch successfully, thank you!
I was able to add an in-game debug console so I can view logs on the Switch, but I'm having difficulty forwarding the logs to the SD card. I created a C++ plugin that mounts the SD card and writes to it, but it's crashing on load and I suspect it has to do with perms for the SD card outside of a development build. Could you provide insight?
 
Last edited by CompuGeniusPrograms,

tempaccount42069

New Member
Newbie
Joined
Apr 7, 2024
Messages
1
Trophies
0
Age
39
XP
9
Country
Russia
Hey Slluxx, great tutorial. I made a quick script to automatically set the system path variables. Just put the script into the root of the folder where you extracted everything and it'll handle all the things for you!

Code:
@echo off
SET currentdir=%cd%
setx /M NINTENDO_SDK_NEX_ROOT %currentdir%\NintendoSDK-NEX
setx /M NINTENDO_SDK_NPLN_ROOT %currentdir%\NintendoSDK-NPLN
setx /M NINTENDO_SDK_PIA_ROOT %currentdir%\NintendoSDK-Pia6
setx /M NINTENDO_SDK_ROOT %currentdir%\NintendoSDK

Make sure to run the batch file as admin!
Post automatically merged:

- Building Library\Bee\artificats\AppPkg\<some id>\main.npdm failed with output: The system cannot find the path specified
This error took me a while to fix, but after snooping through everything, I managed to figure out the issue. You need to install the dotnet 6.0 SDK x64 (Make sure you reboot your computer after installing it.)
This didn't fix it for me but what did fix it is installing everything in the "NintendoSDK\Installers" folder, then running the "SdkEnvironmentChecker.bat" file in the root of the SDK to see if everything was installed correctly. Everything should show up green except for the GPU code driver
 
Last edited by tempaccount42069,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Lol rappers still promoting crypto