Skip to content

Small example project showing how Unity WebGL build could be incorporated and used within ASP.NET Core web application with MVC framework.

License

Notifications You must be signed in to change notification settings

synboxdev/AspNetCore-Unity-WebGL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AspNetCore Web Application + Unity WebGL

📄 Table of contents

About

This repository is a small example of how Unity WebGL build could be incorporated and used within ASP.NET Core web application with MVC framework.

Goal was to create minimum viable product of a ASP.NET Core web application, with bare minimum configuration and simple, straight to the point project structure.

Technology stack

Web app specifics

Using Visual Studio 2022, I've picked ASP.NET Core Web App (Model-View-Controller) as the template for this project.

Unity Engine specifics

At the time of writing this, using Unity Hub (3.10.0) and Unity Editor (6000.0.25f1), I've picked '2D Platformer Microgame' free project template, available during project creation in Unity Hub. Simple, lightweight sample project, which can be built into a WebGL.

The only settings that were adjusted during creation of the actual WebGL builds were the following (Read more here):

  • Decompression Fallback (Determines how Unity processes downloaded files when the build runs in the browser) - ENABLED for all three builds.
  • Compression Format - I've built the project with all three available compression formats - 'No compression', 'Brotli compression' and 'Gzip compression'.

Getting started

Prerequisites

Getting the project

There are multiple ways of doing this. Here's two:

  1. Method 1 - run the following command using a CMD terminal in an empty directory:

    git clone https://github.com/synboxdev/AspNetCore-Unity-WebGL.git

Afterwards, the project's repository will be downloaded to the directory inside of which you've ran this command.

  1. Method 2 - Downloading zipped repository and extracting it locally. Download zipped repository, and extract the files to a folder of your choosing.

Running the project

Once you've retrieved the repository to your local machine, before running the following, do the following:

  1. Build the solution to restore dependencies.
  2. Start the project with one of the methods described below

CMD

You start the project locally, by executing the following command in the root directory of the solution

dotnet run Bacchus

And then open the following URL in your browser - https://localhost:7185 or http://localhost:5288

IDE Tooling

If you are using Visual Studio - you can simply start the project with the GUI interface - navigate to 'Debug' tab -> 'Start without debugging'. Or use the default shortcut of CTRL + F5.

Docker

Open up a command-line terminal in the root directory of the solution, and run the two following commands:

docker build -t bacchus .
docker run -p 443:8080 bacchus

Once that's done - the project should be up and running in a newly created docker container, accessible via browser on http://localhost:443

Credits & Licensing

This project is licensed under the MIT License.

For any and all inquires, feel free to contact me.

About

Small example project showing how Unity WebGL build could be incorporated and used within ASP.NET Core web application with MVC framework.

Topics

Resources

License

Stars

Watchers

Forks