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 jwoodsco · Sep 11, 2015 at 04:42 PM · unity 5networkingupdatesynchosting

SyncVars not updating on client

I'm new to unity and trying to setup a simple chat system to better understand its networking api.

The system works perfectly when I play it from the Unity Editor, however if I launch as a standalone player my SyncVars never get updated.

Log File

 Mono path[0] = 'C:/Users/james/Projects/Unity/Nuclear God Wren/NetworkingTests_Data/Managed'
 Mono path[1] = 'C:/Users/james/Projects/Unity/Nuclear God Wren/NetworkingTests_Data/Mono'
 Mono config path = 'C:/Users/james/Projects/Unity/Nuclear God Wren/NetworkingTests_Data/Mono/etc'
 PlayerConnection initialized from C:/Users/james/Projects/Unity/Nuclear God Wren/NetworkingTests_Data (debug = 0)
 PlayerConnection initialized network socket : 0.0.0.0 55384
 Multi-casting "[IP] 192.168.1.10 [Port] 55384 [Flags] 3 [Guid] 2726845891 [EditorId] 1859337087 [Version] 1048832 [Id] WindowsPlayer(haru) [Debug] 1" to [225.0.0.222:54997]...
 Waiting for connection from host on [192.168.1.10:55384]...
 PlayerConnection accepted from [192.168.1.10] handle:0x27c
 Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,defer=y,address=0.0.0.0:56891
 PlayerConnection already initialized - listening to [192.168.1.10:55384]
 Initialize engine version: 5.2.0f3 (e7947df39b5c)
 GfxDevice: creating device client; threaded=1
 Direct3D:
     Version:  Direct3D 11.0 [level 11.0]
     Renderer: NVIDIA GeForce GTX 750 Ti (ID=0x1380)
     Vendor:   NVIDIA
     VRAM:     1993 MB
 Begin MonoManager ReloadAssembly
 Platform assembly: C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\UnityEngine.dll (this message is harmless)
 Loading C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\UnityEngine.dll into Unity Child Domain
 Platform assembly: C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\Assembly-CSharp.dll (this message is harmless)
 Loading C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\Assembly-CSharp.dll into Unity Child Domain
 Platform assembly: C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\UnityEngine.UI.dll (this message is harmless)
 Loading C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\UnityEngine.UI.dll into Unity Child Domain
 Platform assembly: C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\UnityEngine.Networking.dll (this message is harmless)
 Loading C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\UnityEngine.Networking.dll into Unity Child Domain
 Platform assembly: C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\System.Core.dll (this message is harmless)
 - Completed reload, in  0.090 seconds
 desktop: 1600x900 60Hz; virtual: 1600x900 at 0,0
 <RI> Initializing input.
 
 XInput1_3.dll not found. Trying XInput9_1_0.dll instead...
 <RI> Input initialized.
 
 <RI> Initialized touch support.
 
 Platform assembly: C:\Users\james\Projects\Unity\Nuclear God Wren\NetworkingTests_Data\Managed\System.dll (this message is harmless)
 Setting up 1 worker threads for Enlighten.
   Thread -> id: 1408 -> priority: 1 
 Unloading 3 Unused Serialized files (Serialized files now loaded: 0)
 UnloadTime: 6.865514 ms
 NullReferenceException: Object reference not set to an instance of an object
   at Chatroom.Awake () [0x00000] in C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chatroom\Chatroom.cs:16 
  
 (Filename: C:/Users/james/Projects/Unity/Nuclear God Wren/Assets/scripts/Chatroom/Chatroom.cs Line: 16)
 
 Loading ChatManager
 UnityEngine.Debug:Internal_Log(Int32, String, Object)
 UnityEngine.Debug:Log(Object)
 ChatManager:Awake() (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:42)
 UnityEngine.GameObject:SetActive(Boolean)
 UnityEngine.Networking.NetworkServer:SpawnObjects() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1749)
 UnityEngine.Networking.NetworkManager:FinishLoadScene() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:545)
 UnityEngine.Networking.NetworkManager:UpdateScene() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:568)
 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:889)
  
 (Filename: C:/Users/james/Projects/Unity/Nuclear God Wren/Assets/scripts/Chat/ChatManager.cs Line: 42)
 
 Chat log has updated
 UnityEngine.Debug:Internal_Log(Int32, String, Object)
 UnityEngine.Debug:Log(Object)
 ChatManager:onLogChange(String) (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:72)
 ChatManager:set_Networklog(String)
 ChatManager:Awake() (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:44)
 UnityEngine.GameObject:SetActive(Boolean)
 UnityEngine.Networking.NetworkServer:SpawnObjects() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1749)
 UnityEngine.Networking.NetworkManager:FinishLoadScene() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:545)
 UnityEngine.Networking.NetworkManager:UpdateScene() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:568)
 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:889)
  
 (Filename: C:/Users/james/Projects/Unity/Nuclear God Wren/Assets/scripts/Chat/ChatManager.cs Line: 72)
 
 Registering server handlers
 UnityEngine.Debug:Internal_Log(Int32, String, Object)
 UnityEngine.Debug:Log(Object)
 ChatManager:registerHandlers() (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:53)
 ChatManager:Awake() (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:45)
 UnityEngine.GameObject:SetActive(Boolean)
 UnityEngine.Networking.NetworkServer:SpawnObjects() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1749)
 UnityEngine.Networking.NetworkManager:FinishLoadScene() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:545)
 UnityEngine.Networking.NetworkManager:UpdateScene() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:568)
 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:889)
  
 (Filename: C:/Users/james/Projects/Unity/Nuclear God Wren/Assets/scripts/Chat/ChatManager.cs Line: 53)
 
 System memory in use before: 20.7 MB.
 System memory in use after: 20.7 MB.
 
 Unloading 2 unused Assets to reduce memory usage. Loaded Objects now: 247.
 Total: 0.575672 ms (FindLiveObjects: 0.029119 ms CreateObjectMapping: 0.041279 ms MarkObjects: 0.494713 ms  DeleteObjects: 0.008319 ms)
 
 Sending ChatMessage
 UnityEngine.Debug:Internal_Log(Int32, String, Object)
 UnityEngine.Debug:Log(Object)
 ChatManager:SendChat(ChatMessage) (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:23)
 Chatroom:onClickSendChatButton() (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chatroom\Chatroom.cs:37)
 UnityEngine.Events.InvokableCall:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:149)
 UnityEngine.Events.InvokableCallList:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:626)
 UnityEngine.Events.UnityEventBase:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:766)
 UnityEngine.Events.UnityEvent:Invoke() (at C:\buildslave\unity\build\Runtime\Export\UnityEvent_0.cs:54)
 UnityEngine.UI.Button:Press() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\UI\Core\Button.cs:35)
 UnityEngine.UI.Button:OnPointerClick(PointerEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\UI\Core\Button.cs:44)
 UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\ExecuteEvents.cs:52)
 UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\ExecuteEvents.cs:269)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:378)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:277)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:265)
 UnityEngine.EventSystems.StandaloneInputModule:Process() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:179)
 UnityEngine.EventSystems.EventSystem:Update() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\EventSystem.cs:277)
  
 (Filename: C:/Users/james/Projects/Unity/Nuclear God Wren/Assets/scripts/Chat/ChatManager.cs Line: 23)
 
 Received Chat Message.
 UnityEngine.Debug:Internal_Log(Int32, String, Object)
 UnityEngine.Debug:Log(Object)
 ChatManager:onChatMessage(NetworkMessage) (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:62)
 UnityEngine.Networking.NetworkConnection:InvokeHandler(Int16, NetworkReader, Int32) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:183)
 UnityEngine.Networking.NetworkServer:InvokeHandlerOnServer(ULocalConnectionToServer, Int16, MessageBase, Int32) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1643)
 UnityEngine.Networking.ULocalConnectionToServer:Send(Int16, MessageBase) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\LocalConnections.cs:83)
 UnityEngine.Networking.NetworkClient:Send(Int16, MessageBase) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:372)
 ChatManager:SendChat(ChatMessage) (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:34)
 Chatroom:onClickSendChatButton() (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chatroom\Chatroom.cs:37)
 UnityEngine.Events.InvokableCall:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:149)
 UnityEngine.Events.InvokableCallList:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:626)
 UnityEngine.Events.UnityEventBase:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:766)
 UnityEngine.Events.UnityEvent:Invoke() (at C:\buildslave\unity\build\Runtime\Export\UnityEvent_0.cs:54)
 UnityEngine.UI.Button:Press() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\UI\Core\Button.cs:35)
 UnityEngine.UI.Button:OnPointerClick(PointerEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\UI\Core\Button.cs:44)
 UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\ExecuteEvents.cs:52)
 UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\ExecuteEvents.cs:269)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:378)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:277)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:265)
 UnityEngine.EventSystems.StandaloneInputModule:Process() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:179)
 UnityEngine.EventSystems.EventSystem:Update() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\EventSystem.cs:277)
  
 (Filename: C:/Users/james/Projects/Unity/Nuclear God Wren/Assets/scripts/Chat/ChatManager.cs Line: 62)
 
 Chat log has updated
 UnityEngine.Debug:Internal_Log(Int32, String, Object)
 UnityEngine.Debug:Log(Object)
 ChatManager:onLogChange(String) (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:72)
 ChatManager:set_Networklog(String)
 ChatManager:onChatMessage(NetworkMessage) (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:66)
 UnityEngine.Networking.NetworkConnection:InvokeHandler(Int16, NetworkReader, Int32) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:183)
 UnityEngine.Networking.NetworkServer:InvokeHandlerOnServer(ULocalConnectionToServer, Int16, MessageBase, Int32) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1643)
 UnityEngine.Networking.ULocalConnectionToServer:Send(Int16, MessageBase) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\LocalConnections.cs:83)
 UnityEngine.Networking.NetworkClient:Send(Int16, MessageBase) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:372)
 ChatManager:SendChat(ChatMessage) (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chat\ChatManager.cs:34)
 Chatroom:onClickSendChatButton() (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chatroom\Chatroom.cs:37)
 UnityEngine.Events.InvokableCall:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:149)
 UnityEngine.Events.InvokableCallList:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:626)
 UnityEngine.Events.UnityEventBase:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:766)
 UnityEngine.Events.UnityEvent:Invoke() (at C:\buildslave\unity\build\Runtime\Export\UnityEvent_0.cs:54)
 UnityEngine.UI.Button:Press() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\UI\Core\Button.cs:35)
 UnityEngine.UI.Button:OnPointerClick(PointerEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\UI\Core\Button.cs:44)
 UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\ExecuteEvents.cs:52)
 UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\ExecuteEvents.cs:269)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:378)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:277)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:265)
 UnityEngine.EventSystems.StandaloneInputModule:Process() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:179)
 UnityEngine.EventSystems.EventSystem:Update() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\EventSystem.cs:277)
  
 (Filename: C:/Users/james/Projects/Unity/Nuclear God Wren/Assets/scripts/Chat/ChatManager.cs Line: 72)
 
 Succesfully sent ChatMessage
 UnityEngine.Debug:Internal_Log(Int32, String, Object)
 UnityEngine.Debug:Log(Object)
 Chatroom:onClickSendChatButton() (at C:\Users\james\Projects\Unity\Nuclear God Wren\Assets\scripts\Chatroom\Chatroom.cs:38)
 UnityEngine.Events.InvokableCall:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:149)
 UnityEngine.Events.InvokableCallList:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:626)
 UnityEngine.Events.UnityEventBase:Invoke(Object[]) (at C:\buildslave\unity\build\Runtime\Export\UnityEvent.cs:766)
 UnityEngine.Events.UnityEvent:Invoke() (at C:\buildslave\unity\build\Runtime\Export\UnityEvent_0.cs:54)
 UnityEngine.UI.Button:Press() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\UI\Core\Button.cs:35)
 UnityEngine.UI.Button:OnPointerClick(PointerEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\UI\Core\Button.cs:44)
 UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\ExecuteEvents.cs:52)
 UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\ExecuteEvents.cs:269)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:378)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32) (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:277)
 UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:265)
 UnityEngine.EventSystems.StandaloneInputModule:Process() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\InputModules\StandaloneInputModule.cs:179)
 UnityEngine.EventSystems.EventSystem:Update() (at C:\buildslave\unity\build\Extensions\guisystem\UnityEngine.UI\EventSystem\EventSystem.cs:277)
  
 (Filename: C:/Users/james/Projects/Unity/Nuclear God Wren/Assets/scripts/Chatroom/Chatroom.cs Line: 38)
 
 Waiting for finish
 

MainMenu.cs (the offline scene)

 using UnityEngine;
 using System.Collections;
 
 public class MainMenu : MonoBehaviour {
 
     public void onClickLaunchClient()
     {
         NetManager.singleton.StartClient ();
     }
 
     public void onClickLaunchHost()
     {
         NetManager.singleton.StartHost ();
     }
 
     public void onClickExit()
     {
         Application.Quit ();
     }
 }
 

Chatroom.cs (The online scene)

 using UnityEngine;
 using System.Collections;
 
 using UnityEngine.UI;
 
 public class Chatroom : MonoBehaviour {
     
     public InputField messageInputField;
     public Text logText;
     public Button sendChatButton;
 
     ChatManager chatManager;
 
     void Awake()
     {
         this.chatManager = GameObject.Find ("ChatManager").GetComponent<ChatManager> ();
     }
     
     void Update()
     {
         // Return key sends the message.
         if (Input.GetKeyDown(KeyCode.Return)) {
             this.onClickSendChatButton();
         }
 
         this.logText.text = chatManager.Log;
     }
     
     public void onClickSendChatButton()
     {
         if (string.IsNullOrEmpty (this.messageInputField.text))
             return;
 
         // TODO replace "Test Handle" with a user name tag
         ChatMessage message = new ChatMessage ("Test Handle", this.messageInputField.text + "\n");
 
         if (ChatManager.SendChat (message)) {
             Debug.Log("Succesfully sent ChatMessage");
             this.messageInputField.text = "";
         } else {
             Debug.LogError ("Failed to send ChatMessage");
         }
     }
 }

ChatManager.cs

 using UnityEngine;
 using System.Collections;
 
 using UnityEngine.Networking;
 
 public class ChatManager : NetworkBehaviour
 {
     [SyncVar(hook="onLogChange")]
     string log;
 
     // ACCESSORS //
 
     public string Log
     {
         get {
             return this.log;
         }
     }
 
     [Client]
     public static bool SendChat (ChatMessage message)
     {
         Debug.Log ("Sending ChatMessage");
 
         if (!NetManager.singleton.IsClientConnected()) {
 
             Debug.LogError("NetworkClient is not connected.");
             return false;
 
 
 
         } // else
 
         return NetManager.singleton.client.Send ((short)NetMsgType.CHAT_MESSAGE, message);
     }
 
     // DELEGATES //
     
 
     void Awake()
     {
         Debug.Log ("Loading ChatManager");
 
         this.log = "";
         this.registerHandlers ();
     }
 
     // METHODS //
 
     [ServerCallback]
     void registerHandlers()
     {
         Debug.Log("Registering server handlers");
         NetworkServer.RegisterHandler ((short)NetMsgType.CHAT_MESSAGE, onChatMessage);
     }
 
     // CALLBACKS //
 
     [Server]
     void onChatMessage(NetworkMessage message)
     {
         Debug.Log ("Received Chat Message.");
 
         ChatMessage chatMessage = message.ReadMessage<ChatMessage> ();
 
         this.log += chatMessage.SenderHandle + ": " + chatMessage.Message;
     }
     
     [Client]
     void onLogChange(string log)
     {
         Debug.Log ("Chat log has updated");
     }
 }
 
 




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

1 Reply

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

Answer by jwoodsco · Sep 11, 2015 at 05:59 PM

I was able to solve the problem by changing my Awake() in Chatroom.cs to

     void Awake()
     {
         //this.chatManager = GameObject.Find ("ChatManager").GetComponent<ChatManager> ();
         this.chatManager = this.gameObject.AddComponent<ChatManager> ();
     }

Although this isn't a permanent solution since I want to be able to add and use the ChatManager from the unity editor.

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

33 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

Related Questions

[UNET] send a string for other clients from server problem in UNET 2 Answers

[UNET] Method called on client but not on host player 0 Answers

SyncVar, Command and Authority problem 1 Answer

How to count score on all players from non player object 0 Answers

How do I get the true position (Vector 3) from a Network Transform Component(Unet)? 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