PROBLEM
When I try and call get pixels/read pixels to take a screenshot of my game it fails with this exception
SecurityException: Reading from the screen is not allowed when you have used a downloaded texture without proper crossdomain.xml authorization
UnityEngine.Texture2D.ReadPixels (Rect source, Int32 destX, Int32 destY)
DETAILS of how things are setup
-
I run my game from some domain (myotherdomain.com/game.unity3d).
-
Textures are downloaded from Amazon S3 bucket, example the URL looks like this:
http://mybucketname.s3.amazonaws.com/image.png
- Cross domain policy stored in ROOT of amazon bucket
http://mybucketname.s3.amazonaws.com/crossdomain.xml
-
Contents of cross domain look like this (I’ve actually tried many permutations of this - this is what it is currently):
SUGGESTIONS?
What am I doing wrong?
UPDATE
It turns out that there was no security expection after all - well, Unity was throwing this error - but it was due to calling ReadPixels without waiting for the end of frame in my coroutine. I added the following line before readPixels
yield return new WaitForEndOfFrame
And it worked! The security exception went away. So, I’m guessing this is a bug inside of Unity. Appreciate all the help.