.NET Aspire is a new application model for building distributed apps with cloud-native building blocks. It’s great for wiring together APIs, databases, and background workers.
But what if you also want to bring Unity3D into the mix? 🎮
That’s exactly what I’ve been experimenting with in Aspire.Unity
. It’s an AppHost extension that allows you to start and stop Unity projects as part of your Aspire application.
⚠️ Heads up: This project is experimental — I’m not sure yet how far I’ll take it. But it’s already fun to play with, and it might spark ideas for others.
Why?
When experimenting with distributed apps, I wanted to:
- Run a Unity3D project as part of the same lifecycle as my other Aspire services.
- Eventually, be able to pass environment variables into Unity.
- Treat Unity as “just another service” in my app topology.
Imagine a scenario where a Unity frontend visualizes data from Aspire-powered APIs, or where Unity runs simulations controlled by your backend services.
Installing the package
1. Add the .NET Aspire Unity package to your AppHost project
dotnet add package Dutchskull.Aspire.Unity
2. Add the Unity integration side
Open Unity and add this Git-based dependency in the Package Manager:
https://github.com/Dutchskull/Aspire.Unity3D.git?path=/AspireIntegration/Packages/AspireIntegration
Usage
Minimal example
Adding a Unity project to your Aspire AppHost is just one line:
var unity = builder.AddUnityProject("game", "..\\..\\AspireIntegration");
This will:
- Register a Unity project named
game
. - Use the relative path
..\\..\\AspireIntegration
. - Start Unity on the default URL
http://127.0.0.1:54021
.
Advanced usage
If you need more control, the method signature is:
public static IResourceBuilder<UnityProjectResource> AddUnityProject(
this IDistributedApplicationBuilder builder,
string name,
string projectPath,
string url = "http://127.0.0.1",
int port = 54021,
string? customUnityInstallRoot = null)
-
url
→ The base URL for Unity (default:http://127.0.0.1
). -
port
→ The port Unity listens on (default:54021
). -
customUnityInstallRoot
→ (optional) Custom path to your Unity installation.
Example with all arguments:
var unity = builder.AddUnityProject(
name: "game",
projectPath: "..\\..\\AspireIntegration",
url: "http://localhost",
port: 55000,
customUnityInstallRoot: "E:\\Unity"
);
Roadmap
Planned improvements include:
- Passing environment variables into Unity.
- Richer communication between Aspire and Unity (logs, health checks, etc).
- Possibly multi-project support.
Wrapping up
This is still just an experiment, but it already shows what’s possible when bridging Aspire with Unity.
👉 Repo: Dutchskull/Aspire.Unity3D
I’d love to hear your thoughts — how would you use Aspire + Unity together?
Top comments (0)