Skip to content

Instantly share code, notes, and snippets.

@hecomi
Created January 2, 2016 16:44
Show Gist options
  • Save hecomi/c25739785102932c457d to your computer and use it in GitHub Desktop.
Save hecomi/c25739785102932c457d to your computer and use it in GitHub Desktop.
NetworkOperation.cs
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
public class NetworkOperations : MonoBehaviour
{
private NetworkManager manager_;
private bool isBatchmode_ = false;
public string address = "lab.hecomi.com";
public int port = 30001;
public bool isEmulationServer = false;
public bool isHost = false;
void Start()
{
manager_ = GetComponent<NetworkManager>();
manager_.networkAddress = address;
manager_.networkPort = port;
manager_.maxConnections = 200;
isBatchmode_ = (SystemInfo.graphicsDeviceID == 0);
if (isHost) {
manager_.StartHost();
} else if (isBatchmode_ || isEmulationServer) {
Application.targetFrameRate = 30;
manager_.StartServer();
}
}
public void StartClient()
{
manager_.StartClient();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment