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 AhmedGalal1987 · Oct 17, 2016 at 10:43 AM · networkingcanvasbuttons

How to network canvas elements ??

Helllo,

I am developing networking quiz game which 2 players are getting one question with 4 answers.

I want to network the question and its answers in the client but i can't do that. i handled answers like enemies or non-player objects in unity tutorial but no point

How can i do that ?? Also i can't network the text of the question ??

So i want to ask should i handle canvas ui elements with another method or what ?

Thanks in advance :)

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
1

Answer by Eslam-Mohamed · May 17, 2018 at 12:15 PM

I might be mistaken but when you create the player prefab you put the canvas inside as a child. After creating the Canvas object you uncheck his Canvas component(The canvas should disapear from the scene) Then you create a script and put them as a component of your player object prefab. The script should containn the following:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Networking;
 
 public class OnlyLocalCanvas : NetworkBehaviour {
 // Use this for initialization
     void Start()
     {
            if (isLocalPlayer)
            {
                  GetComponentInChildren<Canvas>().enabled = true;
            }
     }
 }

​ Note that the script has a using UnityEngine.Networking; and tthe class is NetworkBehaviour insted of MonoBehaviour.

You should be good to go!

What this does is when a player spawns in the Network that player (And only that player) can see the Canvas! By default the others players canvas are disabled! it only enables yours [ if(isLocalPlayer) ]

Comment
Add comment · Show 1 · 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 ScaryMonsterStudios · Mar 21, 2019 at 11:25 PM 0
Share

This is the corrent answer, but to be clear, the Canvas CO$$anonymous$$PONENT of the Canvas UI is what needs to be disabled.alt text

avatar image
0

Answer by sennin31 · Oct 17, 2016 at 03:00 PM

Hi,

I think the best idea will be to have a server and an API. The server will be the game manager, and will send questions/answers to remote clients (with json, xml, or whatever you want). Everything will be synchronize and manage by the server.

Comment
Add comment · Show 6 · 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 AhmedGalal1987 · Oct 19, 2016 at 10:38 AM 1
Share

Now i am just beginner so i want to use one client as a host. The problem is i can't synchronize any way.

avatar image sennin31 AhmedGalal1987 · Oct 19, 2016 at 01:18 PM 0
Share

Check this doc : https://docs.unity3d.com/$$anonymous$$anual/UNet$$anonymous$$essages.html

You will be able to send integer. This integer could be an index to an array shared in each app. This array could contains questions or/and answers on each client, and the index would allow you to synchronise your UI

avatar image AhmedGalal1987 sennin31 · Oct 19, 2016 at 02:20 PM 0
Share

Can i synchronize ui group of answers with there texts and events ??

Thank you for help at all .. please assist me because i got headache for days on this issue.

Show more comments
avatar image sennin31 · Oct 20, 2016 at 08:38 AM 0
Share

Look at this one : https://unity3d.com/fr/learn/tutorials/topics/multiplayer-networking/networking-player-health?playlist=29690

wich is part of those tutorials : https://unity3d.com/fr/learn/tutorials/topics/multiplayer-networking

You can use [SyncVar] on your index

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

Is it possible to make an online multiplayer 2D game in unity using only the unity UI components 1 Answer

UI Element Transform being set incorrectly 1 Answer

Menu not getting Keyboard Input 0 Answers

Why are my GUI.Button not rendering when running my networked game? 0 Answers

How to change the text of a button with a name from a list without the name repeating? 2 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