public void Setup(IUcProfile profile, IUnityMainThreadDispatcher unityMainThreadDispatcher, SignalBus signalBus, ICommonValues commonValues) { this._profile = profile; this._unityMainThreadDispatcher = unityMainThreadDispatcher; this._signalBus = signalBus; this._commonValues = commonValues; }
public static void Initialise() { if (_instance == null) { _instance = Current(); } }
public static IUnityMainThreadDispatcher Current() { IUnityMainThreadDispatcher dispatcher = null; try { // NOTE: This causes strange behaviour when you do async from the editor while the // game is playing. What happens is the editor async calls end up hooking // the main game loop. Any ideas, let me know how you can find out if you are on // the Game thread, or the Editor thread. #if UNITY_EDITOR // There is an issue here, that being if code is being ran // in the editor UI and in the player, you can end up with editor UI // code running on the player thread. It's backwards. // Not sure how to avoid this for now. if (!Application.isEditor || Application.isPlaying) { dispatcher = UnityGameThreadDispatcher.Instance; } else { dispatcher = UnityEditorThreadDispatcher.Instance; } #else dispatcher = UnityGameThreadDispatcher.Instance; #endif } catch (Exception e) { Debug.LogError("UnityMainThreadDispatcher.Initialise() must be called from the main thread prior to dispatching back to the main thread."); Debug.LogError(e.StackTrace); } return(dispatcher); }
public static IUnityMainThreadDispatcher Current() { IUnityMainThreadDispatcher dispatcher = null; try { // NOTE: This causes strange behaviour when you do async from the editor while the // game is playing. What happens is the editor async calls end up hooking // the main game loop. Any ideas, let me know how you can find out if you are on // the Game thread, or the Editor thread. //if (!Application.isEditor || Application.isPlaying) //{ #if UNITY_CORE_EDITOR dispatcher = UnityEditorThreadDispatcher.Instance; #else dispatcher = UnityGameThreadDispatcher.Instance; #endif } catch (Exception e) { Debug.LogError("UnityMainThreadDispatcher.Initialise() must be called from the main thread prior to dispatching back to the main thread."); } return(dispatcher); }
public static UcSourceInstance GetUcSourceInstanceFromUcSourceAndDtoSourceInstance(UcSource appropriateSource, SourceInstanceDto dtoSourceInstance, float pixelToUnityUnitScale, IUnityMainThreadDispatcher dispatcher) { return(new UcSourceInstance(appropriateSource, dtoSourceInstance.WallId, dtoSourceInstance.X, dtoSourceInstance.Y, dtoSourceInstance.Width, dtoSourceInstance.Height, pixelToUnityUnitScale, dispatcher, dtoSourceInstance.Id)); }
public ExodusGameObject(string color, IUnityMainThreadDispatcher dispatcher, PrimitiveType primitiveType = PrimitiveType.Cube) { this.UnityMainThreadDispatcher = dispatcher; this.ChangeColor(color); this.PrimitiveType = primitiveType; }
public ExodusGameObject(Color color, IUnityMainThreadDispatcher dispatcher, PrimitiveType primitiveType = PrimitiveType.Cube) { this.UnityMainThreadDispatcher = dispatcher; this.Color = color; this.PrimitiveType = primitiveType; }
public static ObservableCollection <UcWall> GetUcWallListFromDtoWallList(IEnumerable <WallDto> dtoWallList, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher dispatcher) { ObservableCollection <UcWall> UcWallList = new ObservableCollection <UcWall>(); foreach (var dtoWall in dtoWallList) { UcWallList.Add(GetUcWallFromDtoWall(dtoWall, pixelToUnityUnitScale, wallCenterLocation, dispatcher)); } return(UcWallList); }
public UcSourceInstance(UcSource source, int wallId, int x, int y, int width, int height, float pixelToUnityUnitScale, IUnityMainThreadDispatcher dispatcher, int sourceInstanceId = 0) : base(source.Name, source.DefaultWidth, source.DefaultHeight, source.Color, source.SourceId) { this.ExodusSourceInstanceGameObject = new ExodusSourceInstanceGameObject(dispatcher, this.Color); this.SourceInstanceId = sourceInstanceId; this.WallId = wallId; this.X = x; this.Y = y; this.Width = width; this.Height = height; this.PixelToUnityUnitScale = pixelToUnityUnitScale; }
public static void HandToThreadAndWait <TPrevious>(Task <TPrevious> task, Action <Task <TPrevious> > action, IUnityMainThreadDispatcher dispatcher) { var t = dispatcher.Enqueue(() => action(task)); t.Wait(); }
//Very bad how i'm not injecting the main thread dispatcher... but this is a prototype and I'm running out of time. public static UcWall GetUcWallFromDtoWall(WallDto dtoWall, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher unityMainThreadDispatcher) { return(new UcWall(dtoWall.Name, dtoWall.Width, dtoWall.Height, new ObservableCollection <UcSourceInstance>(), pixelToUnityUnitScale, wallCenterLocation, unityMainThreadDispatcher, dtoWall.Id)); }
public ExodusSourceInstanceGameObject(IUnityMainThreadDispatcher dispatcher, string hexColor, PrimitiveType primitiveType = PrimitiveType.Cube) : base(hexColor, dispatcher, primitiveType) { }
private static TResult HandToThreadAndWait <TPrevious, TResult>(Task <TPrevious> task, Func <Task <TPrevious>, TResult> func, IUnityMainThreadDispatcher dispatcher) { var t = dispatcher.Enqueue(() => func.Invoke(task)); t.Wait(); return(t.Result); }
public static void ForceInitialise() { _instance = Current(); }
public static ObservableCollection <UcSourceInstance> GetUcSourceInstanceListFromUcSourceListAndDtoSourceInstanceList(IEnumerable <UcSource> UcSourceList, IEnumerable <SourceInstanceDto> dtoSourceInstanceList, float pixelToUnityUnitScale, IUnityMainThreadDispatcher dispatcher) { ObservableCollection <UcSourceInstance> UcSourceInstanceList = new ObservableCollection <UcSourceInstance>(); foreach (var dtoSourceInstance in dtoSourceInstanceList) { UcSource appropriateSource = UcSourceList.FirstOrDefault(s => s.SourceId == dtoSourceInstance.SourceId); if (appropriateSource == null) { continue; } UcSourceInstanceList.Add(GetUcSourceInstanceFromUcSourceAndDtoSourceInstance(appropriateSource, dtoSourceInstance, pixelToUnityUnitScale, dispatcher)); } return(UcSourceInstanceList); }
public static UcPhysicalWall GetUcPhysicalWallFromDtoPhysicalWallAndSourceInstances(PhysicalWallDto dtoPhysicalWall, ObservableCollection <UcSourceInstance> sourceInstances, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher dispatcher) { return(new UcPhysicalWall(dtoPhysicalWall.Name, dtoPhysicalWall.Width, dtoPhysicalWall.Height, sourceInstances, pixelToUnityUnitScale, wallCenterLocation, dispatcher, dtoPhysicalWall.Id)); }
public static ObservableCollection <UcPhysicalWall> GetUcPhysicalWallListFromDtoPhysicalWallList(IEnumerable <UcSourceInstance> sourceInstances, IEnumerable <PhysicalWallDto> dtoPhysicalWallList, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher dispatcher) { ObservableCollection <UcPhysicalWall> UcPhysicalWallList = new ObservableCollection <UcPhysicalWall>(); foreach (var dtoPhysicalWall in dtoPhysicalWallList) { var matchingSourceInstanceList = sourceInstances.Where(s => s.WallId == dtoPhysicalWall.Id); var matchingSourceInstanceOc = new ObservableCollection <UcSourceInstance>(matchingSourceInstanceList); UcPhysicalWallList.Add(PhysicalWallMapper.GetUcPhysicalWallFromDtoPhysicalWallAndSourceInstances(dtoPhysicalWall, matchingSourceInstanceOc, pixelToUnityUnitScale, wallCenterLocation, dispatcher)); } return(UcPhysicalWallList); }
/// <summary> /// The constructor. Takes in base. The other child properties are takenindependently. /// </summary> /// <param name="wall"></param> public UcDigitalWall(UcWall wall, IUnityMainThreadDispatcher dispatcher) : base(wall.Name, wall.Width, wall.Height, wall.SourceInstances, wall.PixelToUnityUnitScale, wall.WallCenterLocation, dispatcher, wall.WallId) { }
/// <summary> /// The constructor. Takes in all properties indivudually. /// </summary> /// <param name="name"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="sourceInstances"></param> public UcDigitalWall(string name, int width, int height, ObservableCollection <UcSourceInstance> sourceInstances, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher dispatcher, int wallId = 0) : base(name, width, height, sourceInstances, pixelToUnityUnitScale, wallCenterLocation, dispatcher, wallId) { }
public void Setup(IUnityMainThreadDispatcher unityMainThreadDispatcher, IUcProfile profile) { this._dispatcher = unityMainThreadDispatcher; this._profile = profile; }
/// <summary> /// The wall constructor /// </summary> /// <param name="name"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="sourceInstances"></param> public UcWall(string name, int width, int height, ObservableCollection <UcSourceInstance> sourceInstances, float pixelToUnityUnitScale, Vector3 wallCenterLocation, IUnityMainThreadDispatcher unityMainThreadDispatcher, int wallId = 0) { this.PixelToUnityUnitScale = pixelToUnityUnitScale; this.WallCenterLocation = wallCenterLocation; this.ExodusWallGameObject = new ExodusWallGameObject(unityMainThreadDispatcher); this.WallId = wallId; this.Name = name; this.Width = width; this.Height = height; this.InitializeWallGameObject(); this.SourceInstances = sourceInstances; }
public void Setup(SignalBus signalBus, IUcSignalrProxy signalrProxy, IUnityMainThreadDispatcher unityMainThreadDispatcher) { this._signalBus = signalBus; this._signalrProxy = signalrProxy; this._unityMainThreadDispatcher = unityMainThreadDispatcher; }