Embedding a Unity3d webplayer


#1

Hi there,

I’m trying to run Unity3D webplayer content within an Electron app, is this possible?
(Note: I’m not talking about WebGL but content that requires the traditional Unity3D webplayer plugin)

Chrome started to deprecate NPAPI support starting from v42.x and removed all functionality with v45.x, which makes Electron v31 the last version I can potentially use for a test.

By default NPAPI support is disabled, so I needed to enabled it by passing “web-preferences”: {“plugins”: true} to the BrowserWindow constructor.

Just to make sure plugins are supported I also added two appendSwitch calls to the main thread.
app.commandLine.appendSwitch(’–enable-npapi’);
app.commandLine.appendSwitch(’–disable-web-security’);

So my main.js looks something like this:

var app = require('app');  // Module to control application life.
app.commandLine.appendSwitch('--enable-npapi');
app.commandLine.appendSwitch('--disable-web-security'); 

var BrowserWindow = require('browser-window');  // Module to create native browser window.

// Report crashes to our server.
require('crash-reporter').start();

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

// Quit when all windows are closed.
app.on('window-all-closed', function() {
  if (process.platform != 'darwin')
    app.quit();
});

// This method will be called when atom-shell has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
  // Create the browser window.
  mainWindow = new BrowserWindow({width: 800, height: 600, "web-preferences": {"plugins": true, "web-security": false}});

  // and load the index.html of the app.
  mainWindow.loadUrl('http://unity3d.com/webplayer');

  // Open the devtools.
  mainWindow.openDevTools();
  
  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
});

To keep things simple I used the default ‘hello world’ electron sample app, and just replaced the loadURL call with ‘http://unity3d.com/webplayer’, where a standard unity webplayer is hosted.

I got Flash plugins working, but unfortunately no Unity3D webplayer content is running.
Not even the console is throwing any errors or hints…

Any thoughts on this one?

Cheers,
Tommy


#2

Have you had any luck with this?


#3

it should work for you. The last version of electron where you can enable unity3D player is 0.31.2. It has chromium version which supports the Unity3Dplayer.

check out this post
https://discuss.atom.io/t/how-to-access-chrome-flags-in-electron/16470/5?u=sarabsandhu