#if UNITY_5_3_OR_NEWER using System; using System.Collections.Generic; using UnityEngine; namespace Passer.RoboidControl.Unity { public class SiteServer : MonoBehaviour { public RoboidControl.SiteServer site; public Queue thingQueue = new(); protected virtual void Awake() { //Console.SetOut(new UnityLogWriter()); site = new(7681); RoboidControl.Thing.OnNewThing += HandleNewThing; } void OnApplicationQuit() { site.Close(); } public void HandleNewThing(RoboidControl.Thing thing) { site.Add(thing, false); thingQueue.Enqueue(thing); } protected virtual void Update() { site.Update((ulong)(Time.time * 1000)); while (thingQueue.TryDequeue(out RoboidControl.Thing thing)) thing.CreateComponent(); } } } #endif