Open achimmihca opened 5 months ago
Unity supports the web as target platform, so it might be possible to build a webapp from the existing Companion App. Thus, this does not necessarily require other web frameworks.
The idea is that the main game serves a webapp of the Companion App on some local port. A QR code can then be used by players to open it on their phone's browser.
Needs a prototype.
I tried a proof of concept (PoC) for serving one Unity game from another Unity game over here: https://github.com/achimmihca/UnityEmbeddedWebServerDemo
It could work, but comes with its own unique challenges
In conclusion, I will not dig deeper for now as I do not want to mess around with SSL certificates. Contributors of a more solid PoC welcome.
I strongly suggest against using the unity app for serving the files because of various convenience and security issues. Instead, how about we use for example nginx to serve the webapp files, also to avoid caching issues while still making use of caching, put the game into a unique name folder (for example commit hash) and just adjust the path to the game in the html file where the game gets embedded. Put all of that into a docker/podman container, so it is only git checkout, a bit of config in a docker-compose.yml and make it ready to start for any admin.
All of this should imho preferably not be hosted on some local network server, but instead on some server in the internet, the desktop app could show a qr code which the client can scan to open the website and already get "connected" to the local game's instance.
Just passing the songs list, user-name, difficulty, avatar selection, a user-selection of songs and similar between the webapp and the desktop app would be easy to do because it is very little amounts of data and doesn't have any legal issues. The companion-microphone-app could also use this qr-code-scan way to discover connectivity for the microphone-data-target.
If we come up with and agree on an API, I'll gladly build, host and maintain a java spring-boot app for the discovery+relay feature on the usplay.net domain. Would be nice if this API could be a bit generic so that other karaoke games / alternative apps can also make use of this service.
Actual behaviour
The Companion App is implemented as second Unity project that is built for Android and iOS.
This has the advantage of a shared code base.
However, it also introduces considerable overhead for maintenance and makes orchestrating releases much harder. Instead of one release there are three: the main game, plus the Companion App for Android on Google Play, plus the Companion App for iOS on Apple App Store.
From user perspective it is also not optiml because one first has to download and install the app.
Finally, a core selling point of UltraStar Play and Melody Mania is extensibility (custom songs, themes, mods, etc.), but the app on the stores is not extensible.
Expected behaviour
It is probably possible to implement the Companion App as static webapp (only HTML, CSS, JavaScript compiled from TypeScript). Even mobile browsers seem to support microphone API on sample levels. This means pitch detection can be done with JavaScript, and the rest are just http requests.
The game could serve the static webapp on some local port and show a QR code for connection with the phone.
In this scenario the Companion App is delivered together with the main game, making releases much easier, no download required by users, and making mods possible (e.g. custom buttons for remote navigation).
For example, a mod could add a page with "quick actions" to the Companion App: https://discord.com/channels/957290213246390352/1143516426842407022
This needs a prototype.