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,

luzifix

Member
Newcomer
Joined
Dec 26, 2023
Messages
7
Trophies
0
Age
30
XP
24
Country
Germany
** 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.

Does anyone know if this statement is still valid, because I've been searching a lot for the Unity Nintendo Switch support setup for version 2022.3.x over the last few days and only found old stuff. And also the statement "downloads have been moved" on the olebeck/unity github page which collect before all the links look not so nice :(
 
Last edited by luzifix,

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
Does anyone know if this statement is still valid, because I've been searching a lot for the Unity Nintendo Switch support setup for version 2022.3.x over the last few days and only found old stuff. And also the statement "downloads have been moved" on the olebeck/unity github page which collect before all the links look not so nice :(
A good "leak" of the sdk usually provides the correct unity addon. If you cant find the link yourself, look for a different sdk
 

luzifix

Member
Newcomer
Joined
Dec 26, 2023
Messages
7
Trophies
0
Age
30
XP
24
Country
Germany
A good "leak" of the sdk usually provides the correct unity addon. If you cant find the link yourself, look for a different sdk

I have already found a "good leak" with an sdk for 15.3.2 and Unity 2022.2.4f1 support where everything works fine. The only thing I am currently looking for is a newer version of the Unity editor support that works with 2022.3.x and my 15.3.2 SDK.

My question was whether or not your statement that the UnitySetup-Nintendo-Switch-Support-for-Editor-*.exe files still exist somewhere on the Unity download server without authentication.
 

Pyoro_

Active Member
Newcomer
Joined
Jul 12, 2020
Messages
38
Trophies
0
Age
54
XP
506
Country
China
I built a unity project and compiled for switch, converting (using the program attached to the op) and launching the NSP after installing gives me a prolonged black screen, then "The software was closed because an error has occured." any help?
stuff like this shows up too, which is slightly worrying.
1703972195807.png
 
Last edited by Pyoro_,

luzifix

Member
Newcomer
Joined
Dec 26, 2023
Messages
7
Trophies
0
Age
30
XP
24
Country
Germany
I built a unity project and compiled for switch, converting (using the program attached to the op) and launching the NSP after installing gives me a prolonged black screen, then "The software was closed because an error has occured." any help?
stuff like this shows up too, which is slightly worrying.
View attachment 411008
Try it with an empty scene first and work your way forward step by step. I had a similar problem and it was related to file access via the System.IO.File.ReadAllBytes function.
 

Pyoro_

Active Member
Newcomer
Joined
Jul 12, 2020
Messages
38
Trophies
0
Age
54
XP
506
Country
China
Try it with an empty scene first and work your way forward step by step. I had a similar problem and it was related to file access via the System.IO.File.ReadAllBytes function.
tried with an empty 3D scene and it still happens.
 

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
tried with an empty 3D scene and it still happens.
It can be many things. An old sdk trying to be used on a newer firmware, wrong or no keyfiles, hacpac not in path, borked build settings in unity and what not. its impossible for us to know. You can check your crash logs in the atmosphere folder and see if you get something of value from it.
 

Pyoro_

Active Member
Newcomer
Joined
Jul 12, 2020
Messages
38
Trophies
0
Age
54
XP
506
Country
China
It can be many things. An old sdk trying to be used on a newer firmware, wrong or no keyfiles, hacpac not in path, borked build settings in unity and what not. its impossible for us to know. You can check your crash logs in the atmosphere folder and see if you get something of value from it.
wait, I have 15.3.0 (I think) can NSP's from that SDK not be installed on the latest firmware?
 

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
I'm thinking it's a keys issue, I have dev.keys and prod.keys, am I missing anything?
If you followed the guide and have a working sdk, then no. thats everything.
Like i said, check the crash logs - otherwise we will just guess.
 

Pyoro_

Active Member
Newcomer
Joined
Jul 12, 2020
Messages
38
Trophies
0
Age
54
XP
506
Country
China
If you followed the guide and have a working sdk, then no. thats everything.
Like i said, check the crash logs - otherwise we will just guess.
yeah it just gives me "software closed because error occured", how do I get the logs for an error like this? sorry if it's a dumb question, I'm new to switch modding.
 

Slluxx

GBATemp Mayor
OP
Developer
Joined
Jul 17, 2019
Messages
607
Trophies
0
XP
2,147
Country
Germany
If you just want to make games, you can use the Switch Godot port. Games build with the sdk are illegal to share as the contain stolen code from nintendo. A Godot game is not just legal but also easier to make and build.

Different log files (Fatal, crash, and what not) are all in the atmosphere folder on the sdcard.
 

luzifix

Member
Newcomer
Joined
Dec 26, 2023
Messages
7
Trophies
0
Age
30
XP
24
Country
Germany
wait, I have 15.3.0 (I think) can NSP's from that SDK not be installed on the latest firmware?
I am using the 15.3.0 SDK with 16.0.3 firmware and AMS 1.5.3IE. You also need working signpatchs on your switch.
For the installation Tinfoil (Ver. 17.0) with the "Install Unsigned Code" option enabled, worked for me well.
 
Last edited by luzifix,
  • Like
Reactions: I pwned U!

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
1706943123168.png

I am getting really tired of seeing this error over and over and over again.
Post automatically merged:

1706943123168.png

I am getting really tired of seeing this error over and over and over again.
changing the file format to what it wants makes it ask you to change the file format to something else to end up back where you started, so if I were to try and change the icon, it would tell me to change it back to the other one. Think of it like asking your parents when you are young to try to buy something but they both say "go talk to the other person" when you go to one of them.
 

Coolsonickirby

Well-Known Member
Member
Joined
Dec 6, 2015
Messages
331
Trophies
0
Age
22
Website
coolsonickirby.com
XP
2,509
Country
United States
View attachment 417902
I am getting really tired of seeing this error over and over and over again.
Post automatically merged:


changing the file format to what it wants makes it ask you to change the file format to something else to end up back where you started, so if I were to try and change the icon, it would tell me to change it back to the other one. Think of it like asking your parents when you are young to try to buy something but they both say "go talk to the other person" when you go to one of them.
If only someone posted a "Potentially Asked Questions" that had this exact problem in it as well as how to solve it.
 

PeaceHacker

Member
Newcomer
Joined
Jan 24, 2021
Messages
16
Trophies
0
XP
139
Country
United States
I will be honest in saying that I genuinely did not see your post on how to fix it until now
Post automatically merged:

I will be honest in saying that I genuinely did not see your post on how to fix it until now
Update:
Same error even after following the instructions
Post automatically merged:

I will be honest in saying that I genuinely did not see your post on how to fix it until now
Post automatically merged:


Update:
Same error even after following the instructions
and I fixed the error

IDK what I did but it's no longer there and the app compiles successfully
 
Last edited by PeaceHacker,

PeaceHacker

Member
Newcomer
Joined
Jan 24, 2021
Messages
16
Trophies
0
XP
139
Country
United States
Yesterday I've decided to try and get into Unity Switch Building. I've ran into a few issues and managed to resolve them, so I'll be putting something akin to a "FAQ" (a PAQ if you will (for potentially asked questions :))) here.

Building Problems PAQ:

- Could not find <ProjectDir>\%NINTENDO_SDK_ROOT%\<SomePath>\Application_<stuff>.nmeta \ %NINTENDO_SDK_ROOT% is not set
For these 2 errors, I made sure to set the %NINTENDO_SDK_ROOT% environment variable, then restarted my computer. That fixed this issue.

- 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.)

- Building Building Library\Bee\artifacts\SwitchPlayerBuildProgram\24pfd\GameAssembly.nso failed with output:

MakeNso INPUT=<nss path>, OUTPUT=<nso path>
An attempt was made to load a program with an incorrect format. (0x8007000B)

This issue comes from trying to use the x86 dotnet SDK. To fix it, make sure you download the x64 dotnet SDK, then re-order them in the PATH environment variable so that the x64 version is over the x86 (aka put the `dotnet` folder that's the child of `Program Files` over the `dotnet` folder that's the child of `Program Files (x86)` (picture example below)) and save it. After that, close all Unity instances and the Unity Hub, then re-open them and build the project.
View attachment 401590
Post automatically merged:

Decompiled OP's executable back into a python script for those who want to be able to modify the repacking process / integrate it into a custom workflow / just doesn't trust random executables.

Python:
import os, sys, shutil, re

#region Setting up the global tools variable used for reference
tools = {
    "authoringTool": "%s/Tools/CommandLineTools/AuthoringTool/AuthoringTool.exe" % os.environ['NINTENDO_SDK_ROOT'],
    "hacPack": "hacpack"
}
#endregion

#region Getting the prod.keys file
prod_keys = os.path.join(os.environ['userprofile'], ".switch", "prod.keys")
if os.path.exists(prod_keys) == False:
    prod_keys = "prod.keys"
    if os.path.exists(prod_keys) == False:
        print("Could not find prod.keys!")
        exit()
#endregion

#region Setting up the NSP File variables
nsp_filePath = sys.argv[1] if len(sys.argv) > 1 else input("Enter the nsp filepath: ")
nsp_fileName = os.path.basename(nsp_filePath)
nsp_parentPath = os.path.dirname(nsp_filePath)
#endregion

#region Getting and setting up the Title ID variable
nsp_titleID = ""
search = re.search(re.compile('0100[A-Za-z0-9]{12}'), nsp_filePath)
if search == None:
    print("Could not find title ID anywhere in the path! Manual Entry Required.")
    nsp_titleID = input("Enter the NSP's title ID: ")
else:
    nsp_titleID = search.group()
    print("Found title ID in path! Title ID: %s" % nsp_titleID)
#endregion

#region Setting up the paths used for extracting
repacker_extract = os.path.join(nsp_parentPath, 'repacker_extract')
tmp_path = os.path.join(os.environ['temp'], "NCA")
#endregion

#region Cleaning up folders made before
shutil.rmtree(repacker_extract, ignore_errors=True)
shutil.rmtree(tmp_path, ignore_errors=True)
shutil.rmtree('hacpack_backup', ignore_errors=True)
#endregion

#region Running the authoring tool and getting the ExeFS and RomFS folders
os.makedirs(repacker_extract, exist_ok=True)
os.system(' '.join([tools["authoringTool"], "extract", "-o", '"%s"' % repacker_extract, '"%s"' % nsp_filePath]))
control_path = None
program_path = None
for x in os.listdir(repacker_extract):
    full_path = os.path.join(repacker_extract, x)
    if os.path.isfile(full_path):
        continue
    if os.path.exists(os.path.join(full_path, "fs0", "control.nacp")):
        control_path = full_path
    elif os.path.exists(os.path.join(full_path, "fs0", "main.npdm")):
        program_path = full_path
    if control_path != None and program_path != None:
        break
if control_path == None:
    print("Could not find control path!")
if program_path == None:
    print("Could not find program path!")
if program_path == None or control_path == None:
    exit()
#endregion

#region Extracting program to get the Program NCA
output = os.popen(' '.join([tools["hacPack"], '-k', '"%s"' % prod_keys, '-o', '"%s"' % tmp_path, '--titleid', nsp_titleID, '--type', 'nca', '--ncatype', 'program', '--exefsdir', '"%s/fs0"' % program_path, '--romfsdir', '"%s/fs1"' % program_path, '--logodir', '"%s/fs2"' % program_path])).read()
print(output)
tmp_program_nca_path = None
for line in output.splitlines():
    if '----> Created Program NCA:' in line:
        tmp_program_nca_path = line[len('----> Created Program NCA:') + 1:].strip()
        break
if tmp_program_nca_path == None:
    print("Failed getting the Program NCA!")
    exit()
#endregion

#region Extracting control to get the Control NCA
output = os.popen(' '.join([tools["hacPack"], '-k', '"%s"' % prod_keys, '-o', '"%s"' % tmp_path, '--titleid', nsp_titleID, '--type', 'nca', '--ncatype', 'control', '--romfsdir', '"%s/fs0"' % control_path])).read()
print(output)
tmp_control_nca_path = None
for line in output.splitlines():
    if '----> Created Control NCA:' in line:
        tmp_control_nca_path = line[len('----> Created Control NCA:') + 1:].strip()
        break
if tmp_control_nca_path == None:
    print("Failed getting the Control NCA!")
    exit()
#endregion

#region Creating Repacked NCA
os.system(' '.join([tools["hacPack"], '-k', '"%s"' % prod_keys, '-o', '"%s"' % tmp_path, '--titleid', nsp_titleID, '--type', 'nca', '--ncatype', 'meta', '--titletype', 'application', '--programnca', '"%s"' % tmp_program_nca_path, '--controlnca', '"%s"' % tmp_control_nca_path]))
#endregion

#region Creating Repacked NSP
output_nsp = "%s_repacked.nsp" % nsp_filePath[:nsp_filePath.rindex(".nsp")]
if os.path.exists(output_nsp):
    os.remove(output_nsp)
os.system(' '.join([tools["hacPack"], '-k', '"%s"' % prod_keys, '-o', '"%s"' % nsp_parentPath, '--titleid', nsp_titleID, '--type', 'nsp', '--ncadir', '"%s"' % tmp_path]))
os.rename(os.path.join(nsp_parentPath, "%s.nsp" % nsp_titleID), output_nsp)
shutil.rmtree(repacker_extract, ignore_errors=True)
shutil.rmtree(tmp_path, ignore_errors=True)
shutil.rmtree('hacpack_backup', ignore_errors=True)
#endregion
could someone create a script that does the reverse of this? (i.e. makes a Retail NSP a Dev NSP)
I am just curious for testing purposes
 

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