- Home /
How to save runtime generated texture in Webplayer to hard drive?
So here is the deal: I am making smt like Paint app, and suddenly fall into problems with saving of drawing result in web-player.
i believe that it is possible to do with WWW class and some html / php (of course if server that hold web-player have some scripts to maintain it). but idea is to make something like standalone application. i mean you just put web-player into /www folder of your server, and everything works perfect without any additional options adjusting\scripts.
so, my first step was using example provided by EncodeToPNG docs.
if i run it as standalone app everything is perfect, but if it is web-player build - it throws error: 'WriteAllBytes' is not a member of 'System.IO.File'.
i found solution here and build web-player. but then when i am trying to save textures web-player gives error.
how to solve this problem without using server as a bump storage for textures? i believe it can be done by WWW class, but i don't know how, trying to solve it right now.
here is actual code of file save\creation
// Encoding
var bytes = tex.EncodeToPNG();
var PathToTexture : String = FilePath +"/" + NameOfGameObject + ".png";
// saving to hard drive
var fs : FileStream = FileStream(PathToTexture, FileMode.CreateNew);
var w : BinaryWriter = BinaryWriter(fs);
w.Write(bytes);
w.Close();
fs.Close();
edit1: looks like official docs saying that saving to hard drive is disabled by security reasons. but how the hell others did it?? lol
Answer by Eric5h5 · Aug 19, 2011 at 10:50 PM
You can't use System.IO when using a webplayer. You could upload to a server using WWW, but you can't write to a user's harddrive.
tyvm for fast respond. did i understand it right: it is not possible to save !!!ANY!!! data on pc by webplayer. right?
hmmm. may be its kinda another question, but its actual for me: can i have some resourses, that player / user will download separatly, and then webplayer will use them? (yes, i understand that this is off topic. all i need is yes or no :) ) (that actually can solve this problem i think)
tyvm :)
The webplayer has no access to the user's harddrive for security reasons, aside from caching assetbundles.
Your answer
Follow this Question
Related Questions
How can I resize an image and save it to disk ? 6 Answers
Is there a way to save a texture to the iPhone/iPad? 2 Answers
Make an Array of Arrays of Textures 1 Answer
[solved] How to save instance of the texture? 2 Answers
Apply texture on prefab 1 Answer