private void Start()
        {
            PrintClientInfo();

            parameters = CreateWorkerConnectionParameters(SpatialOS.Configuration);

            View = new View();
            View.OnDisconnect(SpatialOS.Disconnected);

            deferredActionDispatcher = new DeferredActionDispatcher();
            spatialCommunicator      = new SpatialCommunicator(null, View, deferredActionDispatcher);
            eventHandler             = new DispatchEventHandler(this, spatialCommunicator);

            InitializeEntityPipeline();

            // The current MonoBehaviour could be destroyed in response to aborted connection attempts,
            // causing leaks of unmanaged resources due to in-progress coroutines not running to completion.
            // Create a new host MonoBehaviour and run on it instead.
            var starter = gameObject.GetComponent <ConnectionCoroutineHost>() ?? gameObject.AddComponent <ConnectionCoroutineHost>();

            starter.StartCoroutine(Connect());
        }
示例#2
0
 /// <summary>
 ///     Creates a new Communicator with the given connection and dispatcher.
 /// </summary>
 public SpatialCommunicator(Connection connection, Dispatcher dispatcher, IDeferredActionDispatcher deferredActionDispatcher)
 {
     this.connection = connection;
     this.dispatcher = dispatcher;
     this.deferredActionDispatcher = deferredActionDispatcher;
 }