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 AmbroseFurback · Feb 14, 2017 at 07:08 PM · networkingnetworksyncchat

Chat 5.5 synclist Stuck

I've been beating my head against the proverbial wall on this. I'm using the steps from the skimpy tutorial in that I have a networkmanager, and my players have networkidentity and networktransform. I don't know what is happening here, but my syncliststring does't appear to send changes to any client other than the one who sends the message. What am I missing???

 using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.Networking;
 
 public class ChatController : NetworkBehaviour
 {
     public Text textPrefab;
     public RectTransform contents;
     public float originalHeight;
 
 
     public SyncListString chatLog = new SyncListString();
 
 
 
     void Start() { chatLog.Callback += OnLogChange; }
 
 //    public override void OnStartLocalPlayer() {
 //        base.OnStartLocalPlayer();
 //        Debug.Log(GetPlayerName() + " Local player started");
 //        Debug.Log(chatLog);
 //        chatLog.Callback += OnLogChange;
 //    }
 
 
     private void OnLogChange(SyncList<string>.Operation op, int itemIndex) {
         Text t = Instantiate<Text>(textPrefab, contents.transform);
         t.text = ": " + chatLog[itemIndex];
         //Debug.LogFormat("LogChange:  local={0}, text='{1}', player={2} chatLog size={3}", isLocalPlayer, t.text, GetPlayerName(), chatLog.Count);
         
         
         switch (op) {
             case SyncList<string>.Operation.OP_ADD:
           //      Debug.Log("?????");
 
                 break;
             case SyncList<string>.Operation.OP_CLEAR:
                 break;
             case SyncList<string>.Operation.OP_DIRTY:
                 break;
             case SyncList<string>.Operation.OP_INSERT:
                 break;
             case SyncList<string>.Operation.OP_REMOVE:
                 break;
             case SyncList<string>.Operation.OP_REMOVEAT:
                 break;
             case SyncList<string>.Operation.OP_SET:
                 break;
         }
     }
 
 
     public void Workabout(string text) {
         CmdSendMsg(GetPlayerName() + ": " + text);
     }
 
     [Command]
     public void CmdSendMsg(string text) {
         //Debug.LogFormat("isServer({1}  Connections({0}) " , NetworkServer.connections.Count, isServer);
 
         chatLog.Add(text);
     }
 
 
     string GetPlayerName() {
         return GetComponentInParent<MR_PlayerController>().playerName;
     }
 }
 
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 AmbroseFurback · Feb 14, 2017 at 07:43 PM 0
Share

If I setup my callback in OnStartClient ins$$anonymous$$d of the other options I do see my debug statement (the one that is commented out above at line 32) on both clients. The original sending client updates fine, but the other client is not local so it never puts the text to the screen.

avatar image AmbroseFurback · Feb 17, 2017 at 06:25 PM 0
Share

Unet seems so incredibly brittle I'm debating on dumping it completely. Since I started using it I haven't been able to work on my actual game at all, it is all just frustrating unet issues. It acts like a cheap 3rd party plugin with zero documentation.

1 Reply

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

Answer by AmbroseFurback · Feb 15, 2017 at 02:44 PM

In case anyone is interested, I solved this by eliminating the synclist and just sending manually:

 public class ChatController : NetworkBehaviour
 {
     public Text textPrefab;
     public RectTransform contents;
     public float originalHeight;
 
 
     public override void OnStartLocalPlayer() {
         base.OnStartLocalPlayer();
         MR_NetworkManager.Instance.client.RegisterHandler(MR_MessageTypes.CHAT_MESSAGE, OnChat);
     }
 
 
     void OnChat(NetworkMessage msg) {
         ChatMessage m = msg.ReadMessage<ChatMessage>();
         Instantiate<Text>(textPrefab, contents.transform).text = m.ToString();
     }
 
 
 
     public void Workabout(string text) {
         CmdSendMsg(text);
     }
 
 
     [Command]
     public void CmdSendMsg(string text) {
         ChatMessage msg = new ChatMessage(GetPlayerName(), text);
         NetworkServer.SendUnreliableToAll(MR_MessageTypes.CHAT_MESSAGE, msg);
     }
 
 
 
     string GetPlayerName() {
         return GetComponentInParent<MR_PlayerController>().playerName;
     }
 }

 public class ChatMessage : MessageBase
 {
     public string fromPlayer;
     public string messageText;
 
     public ChatMessage() : base() { }
     public ChatMessage(string from, string text) : base() {
         fromPlayer = from;
         messageText = text;
     }
 
     public override string ToString() {
         if (fromPlayer == null) {
             return "<color=yellow>System: " + messageText + "</color>";
         }
         return fromPlayer + ": " + messageText;
     }
 }
 

I guess synclist isn't ready for prime time.

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 AmbroseFurback · Feb 21, 2017 at 06:53 PM 0
Share

Decided on using LLAPI NetworkTransport ins$$anonymous$$d. Until Unity creates documentation for the HLAPI it isn't worth the hassle.

One note that might help, I discovered that the NetworkTransport doesn't operate correctly if the client or server runs in the editor. I couldn't get it to work until I build the app and ran two instances outside the editor. Very annoying.

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

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

syncvar not changing after command 0 Answers

Network Attributes details 0 Answers

Problem with networking/ Command/ ClientRPC/ multiplayerChat. 0 Answers

Unity Mirror OnStartServer spawn GameObjects 1 Answer

Sync complex variables and components over network 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