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 dodoman · May 07, 2012 at 12:12 PM · wwwnormal mapgetpixelcrossdomain.xml

GetPixel error on downloaded texture even with crossdomain.xml

Hi,

I am trying to download a texture hosted on my domain and apply it as a normal map to my model.

Here is my function that takes in the URL of the normal map, does the required operation on it and applies it.

I am stumped as to why its not working. It works (is able to load the map and perform GetPixel on it) in the editor when I put http://werplay.com (which is my domain) in WWW Security Emulation(under project settings\editor) in the project. Though when I build for web and run, it does not work. I have now put the crossdomain.xml file at the hosting root as well. It is the same xml that unity3d.com uses, just saved it and put it up on my domain.

(actual) location of crossdomain.xml http://werplay.com/crossdomain.xml (sample) location of texture to load, manipulate and apply http://werplay.com/folder1/folder2/normalmap_xx.jpg

Any help would be greatly appreciated :)

 function setNormal(n: String){  
     var myNormal    : WWW = new WWW (n);
     yield myNormal; 
     var normalTexture : Texture2D = new Texture2D(myNormal.texture.width,myNormal.texture.height,TextureFormat.ARGB32,false);
     var loadedTexture : Texture2D = myNormal.texture;
     var x : int;
     var y : int;
     var theColour: Color = new Color();
     for (x = 0; x<loadedTexture.width; x++)
     {
         for (y = 0; y<loadedTexture.height; y++)
         {
             theColour.r = loadedTexture.GetPixel(x,y).g;
             theColour.g = theColour.r;
             theColour.b = theColour.r;
             theColour.a = loadedTexture.GetPixel(x,y).r;
             normalTexture.SetPixel(x,y, theColour);
         }
     }
     normalTexture.Apply();
     normal = normalTexture;
     renderer.material.SetTexture("_BumpMap", normal);
 }
Comment
Add comment · Show 3
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 dodoman · May 07, 2012 at 02:24 PM 0
Share

I have edited the post now.

It works (is able to load the map and perform GetPixel on it) in the editor when I put http://werplay.com (which is my domain) in WWW Security Emulation(under project settingseditor) in the project. Though when I build for web and run, it does not work.

When building for web, is there anything/anywhere I need to specify where to fetch/check crossdomain policy from? (since WWW security emulation I assume is limited to editor testing only)?

avatar image Bunny83 · May 07, 2012 at 02:43 PM 0
Share

Where do you test your webbuild? On your actual server or locally?

avatar image dodoman · May 07, 2012 at 03:30 PM 0
Share

I've tried both locally or putting the built unity + html file on the same server from where it is downloading the image.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · May 07, 2012 at 01:32 PM

Your explanation is very confusing. Does it work or not? And what's the exact question? Do you want it to work without setting the emulation settings?

You need to set the hosting url if you want to access files on your server when you emulating in the editor. This pretends that the webplayer is run on your website.

See the Security Sandbox for more details.

Also what exactly "its not working"? Do you get any errors in the console / logfile?

I've never tried to read out pixels manually from a downloaded image. Does it work when you build for standalone?

Btw. you might want to use Texture2D.GetPixels instead so you get an array of all pixels, you can do your changes and finally write them to the new texture. It's faster than using GetPixel

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

crossdomain.xml on Server Requiring Basic Authorization 0 Answers

asset bundles download problem 0 Answers

Crossdomain woes 2 Answers

WebGL WWW and Localhost CORS 0 Answers

WWW doesn't work on localhost eventhough crossdomain.xml exists 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