- Home /
WebGL ExternalCall screenshot works in Safari and firefox, but not chrome
Hello, I am hoping that someone can help me figure out why this ExternalCall code works for encoding a png screenshot within safari and firefox but results in a unspecified "network error" when used in chrome. or could provide me with a workaround that would work in all 3 browsers.
Thanks!
<script type="text/javascript">
function Download(data,name){
var Download = {
click : function(node) {
var ev = document.createEvent("MouseEvents");
ev.initMouseEvent("click", true, false, self, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
return node.dispatchEvent(ev);
},
encode : function(data) {
return 'data:image/png;base64,' + data ;
},
link : function(data, name){
var a = document.createElement('a');
a.download = name ||
self.location.pathname.slice(self.location.pathname.lastIndexOf('/')+1);
a.href = data || self.location.href;
return a;
}
};
Download.save = function(data, name){
this.click(
this.link( this.encode( data ), name ) ); };
console.log(data);
var img=document.createElement("img");
img.alt= name;
img.src= Download.encode(data);
img.href = Download.save(data,name);
}
</script>
the data being passed into it is a System.Convert.ToBase64String() of an byte[] that is equal to the Texture2D.EncodeToPNG() being read from the camera for the screenshot.
Your answer
Follow this Question
Related Questions
Interact across browser javascipt and unity webgl 2 Answers
I can't Kill or Close the external exe that i already opened from the unity exe ? 0 Answers
Launching multiple Unity games from a single "launcher" game 2 Answers
GetComponent Problem 1 Answer
how to make multiple purchase buttons in just 2 scripts? 0 Answers