• 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
3
Question by kaleetos · Jul 12, 2011 at 10:08 PM · texturenetworkserialize

Streaming textures possible?

Could anyone possibly show me how to transfer the byte[] of a texture from one client to another (using Unity's built in networking if possible). Essentially I would like to stream the texture from an object on client1 to an object on client 2. I would like to do t$$anonymous$$s for as many frames possible (so compression/decompression would be nice). T$$anonymous$$s is for experimental purposes so I'm not as concerned with bandwidth usage as I am with proof of concept. Any help ac$$anonymous$$eving t$$anonymous$$s affect would be greatly appreciated.

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 Chris D · Jul 12, 2011 at 10:39 PM 0
Share

Have you tried anything yet? Do you have some code to poke at?

If you haven't already, check out some wiki scripts; they show some streaming implementation (not for textures that I can see, but it'll give you an overview of how unity handles this stuff) that might be useful to you.

http://www.unifycommunity.com/wiki/index.php?title=Special%3ASearch&redirs=0&search=stream&fulltext=Search&ns0=1

avatar image kaleetos · Jul 12, 2011 at 10:54 PM 0
Share

No. Really I'm just trying to figure out if this is even possible. I do see a library called ulib in the asset store that can serialize arbitrary unity components. However before I spend the $75 I want to know if maybe there is a way to do it with Unity's built in networking.

avatar image McRain · May 08, 2012 at 11:20 AM 0
Share

Hi. In ULIB you can encode texture to bytearray, compress, encode to string and send over RPC to other user.

3 Replies

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

Answer by Dreamora · Jul 12, 2011 at 11:07 PM

With unity networking, nope, not reasonably as you have to convert all to strings and even there you have size limits. But with regular sockets, there is no reason why it shouldn't work

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 Bunny83 · Jul 13, 2011 at 03:06 AM 1
Share

You could even use OnSerializeNetworkView with reliable delta compression and setup your own transfer protocol. There you can stream all kind of data, you just have to make sure that the receiving peer reads the same amount that have been sent.

I use this method for our Hack&Slash game to transfer server snapshots of different sizes but i use unreliable of course ;) You have to serialize always some kind of header so the receiving peer knows what data follows.

So it is possible but i guess it's less limited with sockets. Well, sockets have of course the limitation that you can't open a listening socket in a webplayer while with unity network you can start a server.

avatar image kaleetos · Jul 13, 2011 at 01:04 PM 0
Share

@Warwick- I don't see how I could send the entire Color[] on a per frame basis (the bitstream does not support Color[] serialization). I could probably split up the Color[] into ints and then (on the other end) reconstruct the Color[] and subsequently read the pixels. However this would mean the texture on client B would would be multiple frames behind the texture on client A. I need a way to send the entire texture once per frame.

@Dreamora- This is what I feared haha. I might I have to brush up on my .NET and get hacking away at the network code.

@Bunny- This seems like an interesting idea. Exactly how would I go about setting up a custom transfer protocol that Unity's networking will accept. Is it possible perhaps to combine Warwick's suggestion and yours(send the Color[] from Texture2D.GetPixels through the OnSerializeNetworkView once per frame). If this is possible, this would be ideal. If I may add-- these are not, by any means, large textures so sending the entire texture once per frame should not be a problem as far as bandwidth goes.

avatar image
2

Answer by Waz · Jul 12, 2011 at 11:05 PM

You can use Texture2D's GetPixels, then transfer them the same as any other data.

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 Bunny83 · Jul 13, 2011 at 03:08 AM 0
Share

If you use Texture2D.EncodeToPNG and Texture2D.LoadImage it's at least compressed ;)

avatar image
0

Answer by kaleetos · Jul 17, 2011 at 02:07 PM

To those of you who want to know, Dreamora's suggestion was the route I ended up taking. I turned the textures2d.getpixels into bytes[] and sent them over standard udp sockets. Reconstructed the texture on the other side and voila, streaming textures.

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 · Oct 26, 2011 at 09:15 PM 0
Share

Just curious: what was the application for this? I'm trying to figure out why you'd want to stream a texture that's constantly changing.

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.

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

8 People are following this question.

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

Related Questions

[Solved]Tell everyone what my texture is 0 Answers

Assigning UV Map to model at runtime 0 Answers

Networking Unity can't get players on network to change each others variables. 0 Answers

WWW.texture provides a :"?" texture... 1 Answer

How to display texture/image on the object from the shared folder on the local network? 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