- Home /
How to send large strings from Unity WebGL to javascript browser function
Hi,
I'm using the method described here: WebGL to browser to pass 2 very large strings (1024x1024 textures converted to Base64String) as is a requirement from my client to a function in the browser javascript, but when I print the received strings via "console.log" they aren't complete as if they got cutted.
Any hint in how to solve this problem?
Thanks in advance.
Here is the code Im using in my WebGL plugin:
Save: function(texture1, texture2, customData)
{
window.save(Pointer_stringify(texture1) ,Pointer_stringify (texture2),Pointer_stringify (customData));
}
and here is the current code in my browser javascript:
function save(t1, t2, customData)
{
console.log(t1);
console.log(t2);
console.log(customData);
}
Some things you should clear up:
What is "very large" for you? 200? 2k? 200k? 20$$anonymous$$?
What information does the string contain and in which format? Any special characters like "\0"?
Are you sure that it's not just the console that has a displaylimit for a single line? For example Unity's console has a limit of 65k. If you log something larger it gets truncated. The same limit holds true for most immediate mode gui controls in Unity: GUI.Label / GUI.TextField / GUI.TextArea / ...
edit
Just read that you use base64 for 1024² images. Do you store them as raw data? or do you store them as png? If they are RGBA images that would mean you need at least 4 bytes per pixel. Storing them uncompressed would be total overkill.
Hi @Bunny83,
Thanks for the reply, I'm not sure how many characters does it contain but but if I remember well it was around 25k, as it is converted from a bytes array to base64 string, I cant control whether there are special characters or not. And to pass it to the browser in that format is my client requirement, they then upload it to their servers and do other things with it. I'm not sure if the console limit is what I'm looking at right now with this problem, will do some tests and be back answer. At least they are just RGB.
Answer by coolraiman · May 03, 2016 at 01:50 PM
maybe you could fragment the string in multiple part of a fixed size just like you would split a winrar archive in multiple volume and then display the log of each part.
Your answer
Follow this Question
Related Questions
Import/Export of save file string 0 Answers
How can I get a string to work as the key to a dictionary filled with the text of a www object? 0 Answers
Unity WebGL calling a function from a jslib file in JavaScript(Vue) 0 Answers
WebGL build callback on tab close or browser quit. 1 Answer
WebGL: Interacting with browser scripting unable to call java script method from C# 2 Answers