Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Puggy · Jun 04, 2016 at 03:51 PM · networkingwebgl

Is it possible to get a networked WebGL build to run in single player mode?

I'm building a game (using Unity Networking) that should be playable solo or with friends. I will be launching on PC/Mac, but I'd like to make a WebGL build in the meantime for easier playtesting. It builds fine and, using Websockets, I can connect to the host running in the editor. The Network Manager HUD won't let my WebGL build start the game as a Host though. I am fine with the WebGL build not being able to accept incoming connections, but is it possible to get it running as a Host and just not be able to have friends join?

Comment
Add comment · Show 2
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 Puggy · Jun 13, 2016 at 10:48 AM 0
Share

I've attempted to manually start the game using Network$$anonymous$$anager.StartHost() ins$$anonymous$$d of the Network $$anonymous$$anager HUD, but this doesn't work. No errors are thrown in the browser console, it just doesn't start up properly so my player prefab never gets instantiated, etc. (this does work to start the game in the editor)

The only WebGL option I've been able to get working is connecting as a Client to localhost while I have the editor or another build running as the Host. It won't even use the $$anonymous$$atchmaker. So is a dedicated server required to run a WebGL build that uses Unity Networking?

avatar image Puggy · Jun 13, 2016 at 11:06 AM 0
Share

I've also tried writing some platform specific code along the lines of:

 if(Application.platform == RuntimePlatform.WebGLPlayer) {
             GetComponent<Network$$anonymous$$anager>().enabled = false;
 }

in the hopes that the other networking components would just not do anything while the Network$$anonymous$$anager is disabled. Unfortunately, ins$$anonymous$$d the NetworkIdentities go and disable the game objects that they are on, breaking my game.

EDIT: the docs say this is by design. network identities automatically disable the game object they're added to until the network manager tells them it's time to spawn in the scene

2 Replies

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

Answer by pawell · Dec 26, 2017 at 03:12 PM

I had similar problem. Starting from Unity 5.3.1 it is possible to set NetworkServer.dontListen. This flag can be used to start host in WebGL build with NetworkManager.StartHost().

Disabling server listening is enough because the only problem with starting server in WebGL build is failure to listen on any port (tested in Unity 5.6 and 2017.2). I was ready to modify Unity Networking to accomplish this but it wasn't necessary. This solution doesn't work with Network Manager HUD.

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 Schubkraft · Jun 13, 2016 at 12:28 PM

WebGL can't run as host. Sorry, but that is a limitation of the platform.

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

6 People are following this question.

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

Related Questions

WebGL sockets fails: Attempt to send to not connected connection 0 Answers

WebGL+Unlit Shadergraph Renders Grey 1 Answer

jslib from WebSocket doesn't receive data 2 Answers

What headers can be passed through in web gl 0 Answers

Unity 5.6 Webgl Photon Spawn Error 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