Run Unity3D-Game On GameShell

You just need to create a game by Unity3D(320*240) and export as a WebGL project(the Template is Minimal), then use nw.js to run the game.

See details at GitHub - zzxzzk115/NW-Unity: NW-Unity is a tool for auto packing your Unity WebGL output folder to a NW.js executable folder.

If you have any problems, please contact me.

6 Likes

That’s cool! Can you say something about the performance?

Its performance on 2d game is nice!
I didn’t test 3d game, I’ll try it later.

waiting for video :grinning::grinning::grinning:

Here is my 2D game demo(developing).

see video at https://youtu.be/tHJt8CCIL4k

1 Like

see 2d game at https://youtu.be/tHJt8CCIL4k

1 Like

How do I use nw.js? Do I need to incorporate it into my project somehow? Or does it need to be installed on the gameshell, and if so, how do I go about doing that?

Hi zzxzzk115

First of all thanks for your effort and Git Hub template.
I followed your instruction and when I launch my game on the Gameshell I receive the following popup message :
Your browser does not support WebGL [OK]
(Message probably coming from the UnityLoader.js)

Do you have an idea to bypass that?
Thanks in advance for your help!

Unity 2019.3.12f1
Gamshell Linux 5.3.6-clockworkpi-cpi3armv7|GNU/Linus
OS Image V0.5
nwjs-sdk-v0.27.6-linux-arm

Sorry I’m late here. It’s been a long time. Now Unity has a new project named “Project Tiny” which is based on Unity’s DOTS(Data Oriented Technical Stack). It can export the game by WebGL,too. (asmJS or wasm) It’s performace is really great. Yesterday I tested its’ sample project “TinyGems” and it worked. Now the latest mesa20.1 supports Unity WebGL project and Project Tiny project, but Project Tiny is still an experimental project. When it releases the final version, I’ll try it as soon. About nw.js, it’s just a container. Nw.js can run H5 project. So you need to read the docs at nw.js’s official website. https://nwjs.io/ It always needs a file named ‘package.json’, for GameShell, it’s something like this:

{
    "main": "index.html",
    "name": "game_name",
    "window": {
        "width": 320,
        "height": 240,
        "max_width": 320,
        "max_height": 240,
        "resizable": false,
        "fullscreen": false,
        "frame": false,
        "transparent": true
    }
}

index.html means the entrance. (Which webpage you want to load first)

Hope it could help you.

Hi, there. Last time I said just don’t use lima Driver.
Now you can use it!!!
You can upgrade your mesa to version 20.1:

## swap
sudo fallocate -l 1G ~/swap
sudo chmod 600 ~/swap
sudo mkswap ~/swap
sudo swapon ~/swap

## install the new libdrm
wget https://dri.freedesktop.org/libdrm/libdrm-2.4.101.tar.xz
xz -d  libdrm-2.4.101.tar.xz
tar -xf libdrm-2.4.101.tar
cd libdrm-2.4.101
meson build --prefix=/usr/  
sudo ninja -C build/ install
cd  

## install the mesa master branch 

sudo apt install g++ meson python3-mako zlib1g-dev libexpat1-dev libdrm-dev flex bison libx11-dev libxext-dev libxdamage-dev libxcb-glx0-dev libx11-xcb-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-present-dev libxshmfence-dev libxxf86vm-dev libxrandr-dev libunwind-dev 

git clone https://gitlab.freedesktop.org/mesa/mesa.git
cd mesa

meson build --prefix=/usr/   -Dbuildtype=release   -Dgallium-drivers=kmsro,lima,swrast -Dosmesa=none -Dplatforms=x11,drm,surfaceless -Dllvm=false
sudo mv  /usr/lib/lima /usr/lib/lima.old/
sudo ninja -C build/ install

## Kernel under 5.4. If your gs's linux kernel is under 5.4, you need to execute these commands:

sudo mv /usr/lib/dri/sun4i_drm_dri.so /usr/lib/dri/sun4i_drm_dri.so.old
sudo mv /usr/lib/dri/sun4i-drm_dri.so /usr/lib/dri/sun4i_drm_dri.so

After you upgraded mesa, you can test your game by using Lima Driver.
Have fun!

I started a new project named NW-Unity several days ago.
NW-Unity is a tool for auto packing your Unity WebGL output folder to a NW.js executable folder.

You don’t need to copy/paste/edit things anymore.

It works on GameShell, first you need to upload your Unity-WebGL folder to GameShell, then SSH:

# Install by pip
sudo pip3 install nwunity

# Package your Unity WebGL files on GameShell.
nwunity -d '/path/to/UnityWebGLDir' -n 'MyGame' -p GameShell

Important :
Make sure the OS version of your GameShell is 0.5 or newer.
You have to build and install mesa 20.1 or newer.
Switch the GPU Driver of your GameShell to Lima if it’s not.

First check your mesa version:

DISPLAY=:0 glxinfo | grep "OpenGL version"

If it shows OpenGL version string: 2.1 Mesa 20.0.0, then you have to upgrade the graphics of your GameShell.

Following instructions are from GitHub - zzxzzk115/GameShell-Scripts: Upgrade the functionalities of your GameShell. :

Upgrade graphics:

bash <(curl -s https://raw.githubusercontent.com/zzxzzk115/GameShell-Scripts/main/scripts/graphics/upgrade_graphics.sh)

如果你在中国大陆,请使用以下脚本:

bash <(curl -s https://raw.fastgit.org/zzxzzk115/GameShell-Scripts/main/scripts/graphics/upgrade_graphics_cn.sh)

This will help you automatically install libdrm and mesa21.3.1.

See more details here

Hope you like it~ If you like it, please give me a star~

1 Like