zoukankan      html  css  js  c++  java
  • Network_01

    var remoteIP = "127.0.0.1";
    var remotePort = 25000;
    var ListenPort = 25000;
    var useNAT = false ;
    var yourIP = "";
    var yourPort = "";

    function OnGUI()
    {
      if(Network.peerType == NetworkPeerType.Disconnected)
      {
        if(GUI.Button(Rect(10,10,100,30),"connect"))
        {
          Network.useNat = useNAT;
          Network.Connect(remoteIP,remotePort);
        }
       
        if(GUI.Button(Rect(10,50,100,30),"Start server"))
        {
          Network.useNat = useNAT;
          Network.InitializeServer(4,ListenPort);
         
          for(var go:GameObject in FindObjectsOfType(GameObject))
          {
            go.SendMessage("OnNetworkLoadedLevel",SendMessageOptions.DontRequireReceiver);
           
          }
        }
       
        remoteIP = GUI.TextField(Rect(120,10,100,20),remoteIP);
        remotePort = parseInt(GUI.TextField(Rect(230,10,40,20),remotePort.ToString()));
      }
      else
      {
        var ipaddress = Network.player.ipAddress;
        var port = Network.player.port.ToString();
       
        GUI.Label(Rect(140,20,250,40),"ip address:"+ipaddress+":"+port);
       
        if(GUI.Button(Rect(10,10,100,50),"Disconnect"))
        {
          Network.Disconnect(200);
        }
      }
    }

    function OnConnectedToServer()
    {
      for(var go:GameObject in FindObjectsOfType(GameObject))
      {
        go.SendMessage("OnNetworkLoadedLevel",SendMessageOptions.DontRequireReceiver);
      }
    }

  • 相关阅读:
    word编号变黑块
    恢复未保存的word
    协方差分析
    SAS字体变大
    可变区组长度--区组随机
    adv and disadv of oncology clinical trial endpoints
    非劣效试验界值确定
    Computer Science
    Compuer Science
    随笔
  • 原文地址:https://www.cnblogs.com/softimagewht/p/2132305.html
Copyright © 2011-2022 走看看