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 AndrewSander · May 29, 2013 at 04:44 AM · guinetworkingmultiplayerlobby

How to make GUI update for all players in a networked game?

So i'm working on a board game, like axis and allies or total war, and at the beginning of the game, the players choose their country, the option to choose that country is then removed, leaving text saying the country had been chosen, forcing the rest of the players to choose a different country. All of this works fine until i test it over the network. One of the players will choose britain, the option then becomes grayed out on that computer, however, the option remains on all other instances of the game. How can i update some GUI classes, but not others, like, i only want to update/change for all players the options for choosing a country, not things like the create game button.

 function OnGUI()
 {
     if(britainChosen)
     {
         GUI.Label(Rect(510, 80, 280, 30), "Britain Chosen");
     }
     
     if(showLobby)
     {
          GUI.Box(Rect(500, 25, 300, 25), lobbyName);
          GUI.Box(Rect(500, 55, 300, 300), "Country");
          
          if(britainChosen == false)
          {  
              if(GUI.Button(Rect(510, 80, 280, 30), "Britain"))
              {
                  britainChosen = true;
                  Debug.Log("Chose Britain");
              
                  //setup britain
              }
          }         
          
          if(germanyChosen == false)
          {
              if(GUI.Button(Rect(510, 120, 280, 30), "Germany") && germanyChosen == false)
              {
                  germanyChosen = true;
                  Debug.Log("Chose Germany");
                  
                  //setup germany
              }
          }
     }
 
     if(!Network.isClient && !Network.isServer)
     {
         if(GUI.Button(Rect(btnX, btnY, btnW, btnH), "Create Game"))
         {
             startServer();
         }
         
         if(hostData)
         {
             for(var i : int = 0; i<hostData.length; i++)
             {
                 if(GUI.Button(Rect(btnX * 1.5 + btnW, btnY * 1.2 + (btnH * i), btnW * 3, btnH * 0.5), hostData[i].gameName))
                 {
                     Network.Connect(hostData[i]);
                 }
             }
         }
     }
 }
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 OP_toss · May 29, 2013 at 06:45 PM 0
Share

What your looking for is called an RPC call using the NetworkView component attached to the game object. Use it like so:

this.GetComponent().RPC( "DisableButton", RPC$$anonymous$$ode.ALL_BUFFERED, arg );

This allows you to call methods globally, as the rpcmode is ALL. Read the docs for more info.

NOTE: What you need here though is what's called an Authoritative Server. One of the players or an external Unity scene needs to act as the Server. All players ask the Server what they can do, Server verifies and replies yes or no. In your case, Player tries to take a country, player client asks Server if country is available. If it is, Server makes it unavailable and responds to all clients telling all of them that country is taken. This is a necessary setup to avoid 2 players taking the same country at the same exact time.

Hope this helps!

avatar image AndrewSander · Jun 05, 2013 at 05:34 AM 0
Share

thanks! Works perfectly now

1 Reply

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

Answer by GodClaw · May 29, 2013 at 07:16 PM

I'm pretty sure you'd have to use an RPC call to everyone to let them know if britainChosen == true

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

Unity networking tutorial? 6 Answers

Multiplayer client-detect 1 Answer

Find GameObjects and then add there name to an array? 0 Answers

How to connect to hosted scene (Multiplayer) 2 Answers

More than one connection in the same time using uNet and UnityEngine.Transport ? 1 Answer


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