• 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 /
This question was closed Jan 21, 2013 at 08:59 PM by The-Oddler for the following reason:

Fixed in latest version of Unity 3

avatar image
Question by The-Oddler · Nov 23, 2012 at 09:28 AM · wwwloadimageintotexture

Unity LoadImageIntoTexture() doesn't work in WebPlayer

I'm trying to load images from a different website on my game, using www.LoadImageIntoTexture(...), and t$$anonymous$$s works on the desktop and my iPad. Though it doesn't in the web player. I get the following error:

You are trying to load data from a www stream w$$anonymous$$ch had the following error when downloading. Rejected because no crossdomain.xml policy file was found UnityEngine.WWW:LoadImageIntoTexture(Texture2D)

W$$anonymous$$ch explains the problem very clearly, though there's one weird t$$anonymous$$ng. In the Unity Documentation in "Security Sandbox of the Webplayer" there's an exceptions part that says:

You are allowed to download images from servers that do not have a crossdomain.xml file. However, the only t$$anonymous$$ng you are allowed to do with these images is use them as textures in your scene. You are not allowed to use GetPixel() on them. You are also no longer allowed to read back from the screen. Both attempts will result in a SecurityException being thrown. The reasoning is here is that it's okay to download the image, as long as the content developer gets no access to it. So you can display it to the user, but you cannot send the bytes of the image back to some other server.

So t$$anonymous$$s says it IS allowed... What am I doing wrong? Or is t$$anonymous$$s a bug? :s

The link I'm trying to load is: http://deckbox.org/mtg/Ponder/tooltip (Note: if you go to t$$anonymous$$s link, you'll see a bunch of text, though it is a picture, since it does work in the desktop version of my game.) I also tried t$$anonymous$$s link: http://static.ddmcdn.com/gif/how-to-solve-cat-behavior-problems-2.jpg and t$$anonymous$$s one does work. So there's a $$anonymous$$nt at what's wrong. Lastly, I also tried t$$anonymous$$s link: http://gatherer.wizards.com/Handlers/Image.ashx?name=Ponder&type=card w$$anonymous$$ch does give a proper image when opened in your browser, but doesn't load in the webplayer...

So, I have a vage idea of what's wrong, though no idea how to fix it. Hope someone here can help.

Thanks!

Comment

People who like this

0 Show 0
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

2 Replies

  • Sort: 
avatar image
Best Answer

Answer by The-Oddler · Jan 21, 2013 at 08:58 PM

T$$anonymous$$s problem fixed itself. The newest version of unity 3 solved it for me. I still get a warning in the javascript console, though it does load the image.

Comment

People who like this

0 Show 0 · 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

Answer by Graham-Dunnett · Nov 23, 2012 at 11:11 AM

The web player is designed to enforce some degree of security. If you access a texture, then, as the documentation says, you have permission to fetch it. However, Unity web player needs to know that the file truly is a texture, and that means it needs to be transferred with the correct mime type. If I fetch the headers for the problem texture I get:

 HTTP/1.1 200 OK
 Date: Fri, 23 Nov 2012 11:08:41 GMT
 Server: Apache/2.2.22 (Ubuntu)
 Last-Modified: Wed, 26 Sep 2012 10:18:16 GMT
 Accept-Ranges: bytes
 Content-Length: 31538
 Vary: Accept-Encoding
 Content-Type: text/html

and t$$anonymous$$s says the file is an html page. So, the security sandbox stops you fetc$$anonymous$$ng the page. You could say "well, why can't the web player fetch the file, and examine it to decide if it's allowed or not". We obviously don't do that because we don't want to fetch pages that we are not allowed to fetch. The solution is to simply ask the person hosting the image to fix the headers.

In your t$$anonymous$$rd example the URL asks the server to send somet$$anonymous$$ng. It responds with the correct header and an image. It's irrelevant that the URL doesn't have an image filename explicitly given. Web servers are infinitely easier to understand if you break the mental connection that URI means folder path and filename.

Also, just because Unity web player fetches images for you does not mean you have permission to use the content. If you are planning on making somet$$anonymous$$ng that uses images from other companies you may want to seek their approval.

Comment

People who like this

0 Show 3 · 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 The-Oddler · Nov 23, 2012 at 12:15 PM 0
Share

So why doesn't the third example work? Since that once's mime type is correct, right? And I have permission to use the DeckBox images, that's why I tried his images first ^^ He's working on fixing the mime type, but he's a sole developer and probably has more important thing to do atm :P

avatar image Graham-Dunnett ♦♦ · Nov 23, 2012 at 12:41 PM 0
Share

Sorry, I thought you said the third example worked... it has image/jpeg as the mime type.

avatar image The-Oddler · Nov 23, 2012 at 01:10 PM 0
Share

I clarified my question, I read it again and it indeed was unclear what I meant. But that one doesn't load either, that was why I suspected an extension was needed.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 People are following this question.

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

Related Questions

Error Trying to Download a Image from a Local File 1 Answer

Loading Images using WWW into a different texture format 2 Answers

Glitch when using WWW.LoadImageIntoTexture(...) 2 Answers

Webplayer crash on LoadImageIntoTexture call 1 Answer

How do you download image to UI.Image? 4 Answers


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