• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by DEtH_MoroZ · Aug 19, 2011 at 10:46 PM · texturewebplayerimagesavepng

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DEtH_MoroZ · Aug 19, 2011 at 10:52 PM 0
Share

tyvm for fast respond. did i understand it right: it is not possible to save !!!ANY!!! data on pc by webplayer. right?

avatar image Eric5h5 · Aug 19, 2011 at 11:12 PM 0
Share

Correct .

avatar image DEtH_MoroZ · Aug 19, 2011 at 11:48 PM 0
Share

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 :)

avatar image Eric5h5 · Aug 20, 2011 at 12:51 AM 0
Share

The webplayer has no access to the user's harddrive for security reasons, aside from caching assetbundles.

avatar image DEtH_MoroZ · Aug 20, 2011 at 12:52 AM 0
Share

ok, tyvm alot.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Image Sequence Texture Problem 1 Answer

[C#] put an image in the center of a mesh (no repetition) 1 Answer

How can I resize an image and save it to disk ? 7 Answers

Is there a way to save a texture to the iPhone/iPad? 2 Answers

Create .png file from script, then import as asset 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges