I’ve done this only once. It involves javascript and some code in the game (probably the jslib bits you’ve tried). Here’s what I had:
I made a js plugin called mobileBrowserDetector.jslib
and dropped it in Assets/Plugins/
mergeInto(LibraryManager.library, {
IsMobileBrowser: function() {
return (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent));
},
});
This is all that is in there. It now probably gets built into the game
Then, I had a ‘bootstrap’ script that gets this value and sets a property but it also has a lot of other things, so here’s a quick script that should work
public class GlobalStuff
{
[DllImport("__Internal")]
private static extern bool IsMobileBrowser();
private static bool? _mobileBrowser;
public static bool MobileBrowser
{
get
{
if (!_mobileBrowser.HasValue)
_mobileBrowser = IsMobileBrowser();
return _mobileBrowser.Value;
}
}
}
This just waits for the first time the value is requested (lazy load) and then caches it so it doesn’t have to ask the jslib for the value each time. You should now be able to just do GlobalStuff.MobileBrowser
to check if it’s a mobile browser or not.
I don’t know much about this but it worked for me. Here’s some related documentation