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
1
Question by MobinYaqoob · Feb 29, 2016 at 12:16 PM · unity 5networkingmultiplayer-networking

How to Share UI across multiple client

i am implementing Unity3d Networking i want a UI across same to All Clients not All client has their own UI.Same UI Sharing all client.

When i change the UI parameter so my UI Update all Client are updated .

When i am trying to do this Unity3d Network Manager create a Separate UI for ALL Clients means if i have 10 Clients then Unity3d Create 10 UI For my All Client like MMO games. but scenerio is different.

For Illustratration :- When i connect my client to host unity3d hirarchy has 2 UI's. when 3 client the hirarchy has 3 UI's so on .. but i want to Share a single UI to Across network and change it from Across network is there any method or some thing

Thanks in Advance :)

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 Adam-Buckner ♦♦ · Feb 29, 2016 at 02:58 PM 0
Share

The UI (as far as I know) should not be spawned with the player if it's set up correctly.

Can you tell me more about how you've set up your UI and your GamePlayer Prefabs?

avatar image alandean · May 28, 2016 at 11:38 PM 0
Share

I am also having the same issue, I have an enemy prefab that spawns on the server and is shown on all connected clients, however if it is not the server machine then the UI does not update.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Reachz · May 29, 2016 at 12:59 AM

U can put 1 UI (canvas) in the scene, which could be activated and synchronized with the other cliets if a client connects and then: Assuming there is a Button that does something, which u would then want to happen on all clients, u could do the following:

The button could call a [Command] function, which is executed on the Server. In that function u can then call a [ClientRpc] function from the server and do something in it. This function is executed on all clients, so its basically as if u would press the button on all clients.

I can also imagine another Method maybe more elegant scenario, where the UI updates itself in certain intervalls with [SyncVars] in ur Scripts. U could then call all functions as [Commands] when changing variables. The Change of the variable on the Server would then be synchronized with all clients, and their UIs would update themselves.

Those are just some quick Suggestions, there may be A LOT more ways to achieve this.

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 alandean · May 29, 2016 at 01:19 AM 0
Share
 using UnityEngine;
 using UnityEngine.Networking;
 using System.Collections;
 using UnityEngine.UI;
 
 public class scoreUIControls : NetworkBehaviour {
 
     public Text waveCount;
     public Text waveText;
     public Text getReady;
     public enemySpawn enemyspawn;
 
     // Use this for initialization
     void Start () {
         waveCount.color = new Color(waveCount.color.r, waveCount.color.b, waveCount.color.g, 0.0f);
         waveText.color = new Color(waveText.color.r, waveText.color.b, waveText.color.g, 0.0f);
         getReady.color = new Color(getReady.color.r, getReady.color.b, getReady.color.g, 0.0f);
         StartCoroutine(FadeTextToFullAlpha(2, getReady));
     }
     
     // Update is called once per frame
     void Update () {
         enemyspawn = GameObject.FindGameObjectWithTag("spawn$$anonymous$$anager").GetComponent<enemySpawn>();
 
         if (enemyspawn.firstWave == true) {
             waveCount.text = "1";
             StartCoroutine(FadeTextToFullAlpha(2, waveText));
             StartCoroutine(FadeTextToFullAlpha(2, waveCount));
         }
 
         if (enemyspawn.secondWave == true) {
             waveCount.text = "2";
             StartCoroutine(FadeTextToFullAlpha(2, waveText));
             StartCoroutine(FadeTextToFullAlpha(2, waveCount));
         }
     
     }
 
     public IEnumerator FadeTextToFullAlpha(float t, Text text) {
         text.color = new Color (text.color.r, text.color.g, text.color.b, 0);
         while (text.color.a < 1.0f)
         {
             text.color = new Color(text.color.r, text.color.g, text.color.b, text.color.a + (Time.deltaTime / t));
             yield return null;
         }
     }
 
     public IEnumerator FadeTextToZeroAlpha(float t, Text text) {
         text.color = new Color (text.color.r, text.color.g, text.color.b, 1);
         while (text.color.a > 0.0f)
         {
             text.color = new Color(text.color.r, text.color.g, text.color.b, text.color.a - (Time.deltaTime / t));
             yield return null;
         }
     }
 }

Here is my code and the variables up the top public Text waveCount, public Text waveText, public Text getReady are what I am trying to sync. I hope this makes sense.

avatar image Reachz · May 29, 2016 at 03:43 PM 0
Share

I do not know how ur spawn$$anonymous$$anager works, but i think its only doing its work on the server, so its not used on the clientside. $$anonymous$$aybe because of that, the code inside ur if-statements if (enemyspawn.firstWave == true) is never executed on clientside. But the server could tell all clients to execute the code if u use a [ClientRpc] function, $$anonymous$$aybe that could work?:

 [ServerCallback]
 void Update () {
          enemyspawn = GameObject.FindGameObjectWithTag("spawn$$anonymous$$anager").GetComponent<enemySpawn>();
  
          if (enemyspawn.firstWave == true) {
              Rpc_FirstWave();
          }
  
          if (enemyspawn.secondWave == true) {
              Rpc_SecondWave();
          }
      
      }
 
 [ClientRpc]
 void Rpc_FirstWave(){
     waveCount.text = "1";
     StartCoroutine(FadeTextToFullAlpha(2, waveText));
     StartCoroutine(FadeTextToFullAlpha(2, waveCount));
 }
 
 [ClientRpc]
 void Rpc_SecondWave(){
     waveCount.text = "2";
     StartCoroutine(FadeTextToFullAlpha(2, waveText));
     StartCoroutine(FadeTextToFullAlpha(2, waveCount));
 }


I am also very new to Networking, i dont if this is right, and maybe there are more elegant ways.

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

89 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 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

Unity Unet Online V.S. Local 0 Answers

UNET (Multiplayer) calling [command] function twice 0 Answers

OnLobbyServerSceneLoadedForPlayer not called for client 1 Answer

[UNet] Network Animator transition stutters 0 Answers

How to send Kinect skeleton data through Unity networks (multiplayer) 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