private void Update() { //Client rendering can be turned off by things such as WebGL background throttling //so we should opt not to draw in those cases. if (!RsUnityClient.ShouldClientRender) { return; } DrawableSize = DrawablesList.Count; InGameDrawableSize = InGameDrawablesList.Count; //We need to create a texture if one is requested //has to be done on the main thread in Unity3D if (!TextureCreationRequestQueue.IsEmpty) { TextureCreationRequestQueue.TryDequeue(out var request); Texture2D texture = new Texture2D(request.Width, request.Height, TextureFormat.BGRA32, false, false); texture.wrapMode = TextureWrapMode.Clamp; //Point mode is important otherwise the filtering will cause bleeding by mips at the seams. //texture.filterMode = FilterMode.Point; TextureDictionary[request.Name] = texture; request.CompleteRequest(texture); //If we already have a drawable with this name //we need to remove it from the current draw list //This can happen going from the game back to the titlescreen //and etc. if (Drawables.ContainsKey(request.Name)) { if (!IsIngameImage(request.Name)) { DrawablesList.Remove(Drawables[request.Name]); } else { InGameDrawablesList.Remove(Drawables[request.Name]); } } Drawables[request.Name] = new TextureDrawable(texture, OptionalRenderMaterial); if (!IsIngameImage(request.Name)) { DrawablesList.Add(Drawables[request.Name]); } else { InGameDrawablesList.Add(Drawables[request.Name]); } } }