Problem with LAN multiplayer game in Unity

I'm trying to learn how to make an offline LAN multiplayer game in Unity.

So for example, I make something that can send a text message and make a cube XD

Now this is my problem:

Problem with LAN multiplayer game in Unity

(When I send a message, try connecting to the server, or when I try to create a cube I should first click on the other window!)

StartServer:

    using UnityEngine; using System.Collections;  public class StartServer : MonoBehaviour {     public Transform Taghsimobj;     public Transform Makan;     public Transform CubeOBJ;      public string MSG;      public string ResMsg;      void Ress (string inres) {         ResMsg = inres;      }      void OnGUI () {          if (Network.peerType == NetworkPeerType.Disconnected)         {             if (GUILayout.Button ("StartServer"))             {                 Network.InitializeServer(10, 25000);             }             if (GUILayout.Button ("Connect"))             {                 Network.Connect ("192.168.1.101", 25000);             }          }          else          {             if (GUILayout.Button ("CreatCube"))             {                 Network.Instantiate (CubeOBJ, Makan.transform.position, Makan.transform.rotation, 0);             }             if (GUILayout.Button ("CreatChat"))             {                 Network.Instantiate (Taghsimobj, this.transform.position, this.transform.rotation, 0);             }             if (GUILayout.Button ("SendMessage"))             {                 GameObject.Find ("GameObject(Clone)").GetComponent<NetworkView>().RPC ("ResText", RPCMode.All, MSG);             }             MSG=GUILayout.TextField(MSG);                GUILayout.Box (ResMsg);         }       } } 

taghsim:

    using UnityEngine; using System.Collections;  public class Taghsim : MonoBehaviour {      void Start () {     }      [RPC]     void ResText (string ResIn) {         GameObject.Find ("Main Camera").SendMessage ("Ress", ResIn);      } } 

Replay

Category: unity Time: 2016-07-30 Views: 2
Tags: unity

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.153 (s). 12 q(s)