Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

how to open new tab in webgl browser

Discussion in 'Web' started by A_never_kill, Nov 20, 2018.

  1. A_never_kill

    A_never_kill

    Joined:
    Jan 7, 2014
    Posts:
    81
    I want to open tab with screenshot captured ,so that user can download the image from browser.Is there any way to do this thing.I also try to use js to call browser but unfortunately that is not supported.
     
  2. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    242
  3. A_never_kill

    A_never_kill

    Joined:
    Jan 7, 2014
    Posts:
    81
    I have to make jslib file for below mentioned code??
    Code (JavaScript):
    1. DownloadFile : function(array, size, fileNamePtr)
    2. {
    3.     var fileName = Pointer_stringify(fileNamePtr);
    4.     var bytes = new Uint8Array(size);
    5.     for (var i = 0; i < size; i++)
    6.     {
    7.        bytes[i] = HEAPU8[array + i];
    8.     }
    9.     var blob = new Blob([bytes]);
    10.     var link = document.createElement('a');
    11.     link.href = window.URL.createObjectURL(blob);
    12.     link.download = fileName;
    13.     var event = document.createEvent("MouseEvents");
    14.     event.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
    15.     link.dispatchEvent(event);
    16. }