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
1
Question by Hesta · Mar 04, 2013 at 04:07 PM · networkingnetworkwebcamtexturewebcam

Live webcam stream in unity

So, I've been trying to make a webcam stream where the server sends a live stream from his webcam to the clients on the network. I've tried to write a code myself (I'm not very good at it), but for some reason it doesn't work. Here it is:

 #pragma strict
 
 var webcamTexture : WebCamTexture;
 var data : Color32[];
 
 
 function OnServerInitialized() {
         webcamTexture = WebCamTexture();
            renderer.material.mainTexture = webcamTexture;  
            webcamTexture.Play();
         data = new Color32[webcamTexture.width * webcamTexture.height];
 }
 
 function Update () {
     webcamTexture.GetPixels32 (data);
 }
 
 function OnConnectedToServer() {
        networkView.RPC ("WebcamStream", RPCMode.Others, data, webcamTexture);
     webcamTexture.Play();
 }
 
 @RPC
 function WebcamStream (data : Color32 [], webcamTexture: WebCamTexture) {
     var    newwebcamTexture: WebCamTexture = webcamTexture;
     renderer.material.mainTexture = newwebcamTexture;
      var newdata: Color32[] = data;
     webcamTexture.GetPixels32 (newdata);
 }
 

It just results in a blank screen on the client's side. Any help will be much 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 Benproductions1 · May 22, 2013 at 01:54 AM 0
Share

Do you get any errors? You do know you can't just send textures using the inbuilt Networking

avatar image Hesta · May 23, 2013 at 11:23 AM 0
Share

There was a tutorial I saw, where the guy was able to send textures along the network (when the server clicked a button, the texture of a certain object changed in the whole network). The thing is I can't get that texture to be updated from the webcam display. What do you suggest I do?

avatar image soJackyDev · Apr 07, 2014 at 01:43 PM 0
Share

Can you post the link to that tutorial?

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by flamy · May 23, 2013 at 11:55 AM

Hello,

he problem in your program is that you have used invalid arguments for RPC

Valid RPC parameters are int, float, string, NetworkPlayer, NetworkViewID, Vector3 and Quaternion.

so you cannot pass anything else other than the above in RPC..

In this case you have to use OnSerializeNetworkView for transferring data. And you cannot transfer webcam texture straight away, you have to use GetPixel32 in webcamtexture class. and get the array, use serialize on the array and it would be sent to the other system (This part will be more clear if u check the example in OnSerializeNetworkview page)

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
avatar image
1

Answer by thelghome · Jul 31, 2019 at 06:27 PM

If someone still needs examples, you may try FMETP STREAM | Forum

It provides Streaming Demo with UDP/TCP/WebSocket solution, and Web browser demo with Socket.IO.

All source code are written in C# and easy to modify.

Supported: Android/iOS/Mac/PC/AR/VR/Linux/HoloLens/OculusGO/MagicLeap/WebGL/HTML...etc

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

15 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 avatar image avatar image avatar image avatar image

Related Questions

Cannot get pixels when webcam is not running 0 Answers

New multiplayer setting broke Network Lobby 0 Answers

Official Unity Networking example? 0 Answers

Implementing a news feed into my application 1 Answer

Networking Sync SetActive Not Working 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