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 /
  • Help Room /
avatar image
0
Question by jinnindo · Mar 15, 2016 at 11:07 AM · networkingmultipleselectiononlinescene-change

Unet Online Scene Selector, Choose from multiple maps, etc.

All I want is a way to choose what online level will be loaded. Maybe make it something players in a lobby can vote for, eventually.

I've spent enough time searching to assume that NetworkManager.ServerChangeScene is the answer, but I don't know how it's implemented. The advice I found is written for other knowledgeable programmers, which I am not. Nor are those asking, usually. Still, couldn't hurt to try for myself.

If you could even just direct me to an example where this has been made to work, or tell me what to type where, I can figure out the rest. Please help. Thank you.

Comment
Add comment
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

2 Replies

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

Answer by sovium · Mar 15, 2016 at 09:25 PM

Hello @jinnindo,

When you set your online/offline scene in NetworkManager, a method NetworkManager.ServerChangeScene is called automatically in the background. When this method is called, the NetworkManager.OnServerSceneChanged is called on the server and NetworkManager.OnClientSceneChanged is called on the clients. These methods can be overridden and customized. If you are using the networkmanager, you can get the instance of your networkmanager by writing NetworkManager.singleton.

So at the point where you would like to globally change your scene (server & clients), you should have something like:

 void ChangeScene(string sceneName){
     // Change scene on the server
     NetworkManager.singleton.ServerChangeScene(sceneName);
 }

In addition, according to the documentation you need to set clients to be ready again after changing the scene, so for example you could override the NetworkManager's method:

 public override void OnClientSceneChanged(NetworkConnection conn){
     base.OnClientSceneChanged(conn);
     // Set client as ready
     ClientScene.Ready(conn);
 }

See following links for more information:

NetworkManager.ServerChangeScene

NetworkManager.OnClientSceneChanged

NetworkManager.OnServerSceneChanged

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 jinnindo · Mar 16, 2016 at 08:23 AM 0
Share

I appreciate your response, but I think this highlights the problem.

At best, I have an artist background. I did find the links you shared here, but couldn't make sense of them (hence asking where to put the code). Until! I found that the network starter example here: http://forum.unity3d.com/threads/networking-sample-projects.325096/, which has an implementation of changing online scenes. It is the only example I've found or even heard of.

I still don't know how exactly to choose the online scene, except manually using that button, and only after a scene has already loaded. Players voting on maps is even farther away.

avatar image jinnindo · Mar 21, 2018 at 06:53 AM 0
Share

I came back around to searching for the solution to this problem and found this old question/answer. Since it's been 2 years and I've sort of learned to program in that time, I can now say yours is the correct answer. Thank you, friend!

avatar image
0

Answer by NarxGaming · Sep 06, 2020 at 08:18 AM

A TOTALLY DIFFERENT MAYBE BETTER WAY! if anyone cares hahah =)

you can create Multiple Lobbys as Scenes with seperate instances of Lobby manager with play scene set to some different scene .. then when you Host add a prefix onto match.name ie..

 manager.matchName = "F_" + roomNameField.text ; // An InputField.text


Then when you check for rooms available, you can then only display rooms available to join that have the prefix at beginning ie.

 foreach (var match in manager.matches)
      {
         string checkMatchName = match.name;
         if (checkMatchName.StartsWith("F"))
     {
     if (GUI.Button(new Rect(xpos, ypos, 200, 40), "Join " + match.name))
         {
             manager.matchName = match.name;
             manager.matchSize = (uint)match.currentSize;
                                         
     manager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, manager.OnMatchJoined);
         }
             ypos += spacing;
      }
 }

Thus only Displaying Rooms with the PreFix "F" available to join, so use different PreFixes for different lobbies and Clients can then only connect to Matches in the required lobby =)

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

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

Related Questions

UNET StopServer() without reloading lobby scene 2 Answers

How to make Server Side Bots in Mirror? 0 Answers

Is ther any way to load text after building game 0 Answers

HELP with Unity Networking 0 Answers

How to correctly change scene with a Lobby Manager? 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