Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Julien-Lynge · Feb 23, 2012 at 09:47 PM · webplayerfile-iochrome

File I/O access from Chrome Native Client

With the latest release of Native Client, it now supports disk I/O. This I/O is different than System.File.IO in that it's asynchronous, more analogous to WWW in Unity terminology. From https://developers.google.com/native-client/beta-docs/fileIO

With either of the techniques described above, you can imagine that file IO does not lend itself to a blocking model. As a result, functions like fread/fwrite don't work as intended. To handle file IO in Native Client you must adjust your file manager paradigm to an asynchronous model.

My question is: is there any way to access this functionality from a Unity project compiled for NaCl? Google does provide an example C++ read/write class at http://code.google.com/p/nativeclient-sdk/source/browse/trunk/src/examples/pong/pong.cc, but I have zero experience with C++. We can't just compile this code to a plugin, because as Unity says: "As with the standard webplayer plugin, native C/C++ plugins are not currently supported by NaCl."

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

3 Replies

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

Answer by Julien-Lynge · Feb 24, 2012 at 11:45 PM

I posted this to the forums as well, and a Unity Developer was kind enough to provide an answer:

There is currently no native way to do that in Unity with NaCl. I don't expect that we will directly expose NaCl FileIO APIs any time soon, as they don't map well to existing File.IO functionality (as you described), and exposing a specific NaCl File IO class seems to be too special cased. I think the preferred way for us to expose this would be to add the ability to load plugin DLLs in NaCl, but that is unlikely to happen in the short term either (I think that there are more interesting features to be added to NaCl at this point).

So, right now your only option would indeed be using HTML5 file storage using js. From what I can tell with my limited knowledge of HTML5 file storage, this should generally be possible, though you would probably have to encode the data as text to submit it to Unity.

You can read the whole thing here:

http://forum.unity3d.com/threads/124820-File-I-O-in-Native-Client

Comment
Add comment · 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
0

Answer by Bunny83 · Feb 23, 2012 at 10:23 PM

This is not a question about if it's possible or not. It just doesn't allow you to access local files! All Unity players (standalone / webplayer / Android) are written in native code. In this case there's no problem for the player itself to access everything on the clients PC. The point is that unity created games / apps that are played in the Webplayer aren't allowed to access files.

The Unity3d Webplayer is a trusted piece of software which has to be installed on the clients PC. A game embedded in a website isn't trusted software.

There is no way for content that runs in the Unity webplayer to access local files. There is, will and should be no way to do something like that.

The best i could think of if some kind of drag and drop support, so the user fully controls what files can be read. Here's a feature request for this functionality

Comment
Add comment · Show 1 · 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 Julien-Lynge · Feb 23, 2012 at 10:35 PM 0
Share

I'm not sure I agree with your assessment here. The other webplayer instances have no I/O access because they're sandboxed - it's just not possible to do. Here, NaCl has provided the functionality - it's not random I/O, it's an intentionally 'safe' way that Google has decided to block off disk space within the Native Client sandbox. I've never seen a statement from Unity that they simply won't allow disk access from webplayer if there are no technical limitations.

Furthermore, at this point we're no longer talking about a strict unity webplayer with the trust issues you imply - according to Unity:

"Unity 3.5 offers support to run Unity Web Player content (.unity3d files) using NaCl to allow content to be run without requiring a plugin install in Chrome."

Thus they're providing a wrapper into Native Client, not a browser plugin, and the app is distributed through the Chrome app store. This is somewhat analogous to the iOS/Android model, and Unity certainly doesn't restrict disk access there.

avatar image
0

Answer by jeffssmith1 · Feb 25, 2012 at 03:06 AM

It would be helpful if Unity would post a technical page that explains exactly which NaCl features can be leveraged in Unity and some sample code of how to leverage them.

Being able to read/write from disk is a very powerful NaCl feature and would be extremely useful to Unity developers.

Comment
Add comment · Show 2 · 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 Julien-Lynge · Mar 01, 2012 at 12:28 AM 0
Share

@jeffssmith1

UnityAnswers etiquette is that opinions should be posted as comments rather than an answer. This helps with the flow of the Q&A.

I agree that a page of explanation of Unity in NaCl and what is/isn't implemented would be very useful. However, it sounds like NaCl support is still very much in development/flux, so I don't honestly expect anything for a while.

avatar image jeffssmith1 · Mar 09, 2012 at 08:23 PM 0
Share

$$anonymous$$y humble apologies for the breach in etiquette.

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.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problems with webplayer in chrome on OSX 2 Answers

Why cant some users access my game using Chrome? 1 Answer

Unity Web Player Loses Focus in Chrome 0 Answers

WebPlayer Chrome Extension 0 Answers

File manipulations in the unity web player. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges