Search Unity

Javascript stopped working after upgrade to 5.6

Discussion in 'Web' started by nsmith1024, May 20, 2017.

  1. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    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!!


    Code (JavaScript):
    1.  
    2. var MyPlugin = {
    3.  
    4.  ImageUploaderCaptureClick: function() {
    5.     if (!document.getElementById('ImageUploaderInput')) {
    6.       var fileInput = document.createElement('input');
    7.       fileInput.setAttribute('type', 'file');
    8.       fileInput.setAttribute('id', 'ImageUploaderInput');
    9.       fileInput.style.visibility = 'hidden';
    10.  
    11.       fileInput.onclick = function (event) {
    12.             this.value = null;
    13.       };
    14.       fileInput.onchange = function (event) {
    15.             gameInstance.SendMessage('LocalLoginUpload', 'FileSelected', URL.createObjectURL(event.target.files[0]));
    16.       }
    17.       document.body.appendChild(fileInput);
    18.     }
    19.  
    20.     var OpenFileDialog = function() {
    21.           document.getElementById('ImageUploaderInput').onclick();
    22.          gameInstance.Module.canvas.removeEventListener('onclick', OpenFileDialog);
    23.     };
    24.  
    25.     gameInstance.Module.canvas.addEventListener('onclick', OpenFileDialog, false);
    26.   }
    27. };
    28.  
    29. mergeInto(LibraryManager.library, MyPlugin);
    30.  
    31.  
     
  2. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Never mind, i rewrote it so that it works with 5.6, so it works now.