Hello,
I upgraded from 5.4 to 5.6, but now some of my JavaScript plugin code dont work anymore.
I had an old style OnGUI Button that when clicked would call a Javascript plugin code that displayed the FILE dialog box allowing the user to select a picture to use for his profile.
Now that FILE dialog box doesnt appear anymore since i upgraded to 5.6
Does anybody have any JavaScript plugin code i can use that works with 5.6 that allows the user to select a picture from his computer?
My old code is here, thanks!!
var MyPlugin = {
ImageUploaderCaptureClick: function() {
if (!document.getElementById('ImageUploaderInput')) {
var fileInput = document.createElement('input');
fileInput.setAttribute('type', 'file');
fileInput.setAttribute('id', 'ImageUploaderInput');
fileInput.style.visibility = 'hidden';
fileInput.onclick = function (event) {
this.value = null;
};
fileInput.onchange = function (event) {
gameInstance.SendMessage('LocalLoginUpload', 'FileSelected', URL.createObjectURL(event.target.files[0]));
}
document.body.appendChild(fileInput);
}
var OpenFileDialog = function() {
document.getElementById('ImageUploaderInput').onclick();
gameInstance.Module.canvas.removeEventListener('onclick', OpenFileDialog);
};
gameInstance.Module.canvas.addEventListener('onclick', OpenFileDialog, false);
}
};
mergeInto(LibraryManager.library, MyPlugin);