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 Le-nain · Mar 04, 2013 at 09:32 AM · screenshotwebflashuploadcapture

I need to take a screenshot from a FLASH BUILD

Hi,

As stated in the title, I need to take a screenshot of my scene and afterwards send it to a server. I believe I can handle the uploading on my own using WWWForms, but I can't get the screenshot part to work. I just want to remind you I'm working on a Flash build; as far as I'm concerned, nor Application.CaptureScreenshot() nor Texture.ReadPixels() do work on this platform..

Thanks

Comment
Add comment · Show 6
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 Le-nain · Mar 04, 2013 at 11:02 AM 0
Share

O$$anonymous$$ so basically I have to create a handler in an AS3 clas that will make the screenshot and call it from a C# class. Thanks, it's a bit annoying but at least there's a way to do it! Just a small additionnal question, as I never used AS3 before starting this project: can I access these Stage3D/Context3D from any AS class (are they public static) or do I have to extend a particular one?

avatar image Philipp · Mar 04, 2013 at 11:14 AM 0
Share

You should be able to access them from any class, like so:

 var context:Context3D = UnityNative.stage.stage3Ds[0].context3D;

Yeah, it's annoying, and you're probably going to run into some headaches getting the pixel data back to C#, but it's definitely doable.

One thing you should be aware of: When you're messing with Context3D, it's probably best to do so from an OnPostRender handler in a $$anonymous$$onoBehaviour attached to a camera. The reason for this is that the Unity flash engine is setting and clearing all kinds of state flags and doing a whole lot of other stuff behind the scenes at various times, which can interfere with your own code, if you're accessing Context3D from an Update handler.

avatar image Le-nain · Mar 04, 2013 at 11:41 AM 0
Share

Thanks for the snippet and the tips. I'm already aware about the OnPostRender thing, I'm currently using a coroutine with a yield waitForEndOfFrame; which should do the trick :)

As you're suggesting I'll get some headaches from passing my screenshot back to Unity, would you know by any chance if there is a simple way to upload it directly from AS3 to a server? Because to be fair that's the only reason I need to pass it back to C#, otherwise I don't even display it within my scene.

By the way: I assume your answer is the correct one (considerating the lack of info I managed to get on the internet), I'll just wait for this afternoon to implement it to mark it as such.

avatar image Philipp · Mar 04, 2013 at 11:47 AM 0
Share

I don't have anything in store myself, but I'm sure other people have solved that problem... A quick Google search gives these two posts, for example: http://www.quietless.com/kitchen/upload-bitmapdata-snapshot-to-server-in-as3/ http://www.quietless.com/kitchen/dynamically-create-an-image-in-flash-and-save-it-to-the-desktop-or-server/

avatar image Le-nain · Mar 04, 2013 at 01:48 PM 0
Share

Perfect, managed to get everything up'n'running using the second link, modifying it a bit to use Context3Ds ins$$anonymous$$d of DisplayObjects and then linking everything through Unity in C# and AS.

Thanks for everything.

PS: would you "convert your comment to answer", so that I can accept it as the correct answer and thus give you credit?

Show more comments

1 Reply

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

Answer by Philipp · Mar 04, 2013 at 10:23 AM

Unfortunately, this isn't currently possible from within C# or JS. The only way you're going to get this to work is to dig into Flash's Stage3D API and use Context3D's drawToBitmapData to grab the backbuffer into an AS3 BitmapData.

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

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

Show Screenshot in display. 2 Answers

WebRequests have very slow transfer speed for large uploads 0 Answers

How implement my game on the website? 5 Answers

How to upload a web game to dropbox without errors? 2 Answers

Flash player vs. Unity Web player 0 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