コード例 #1
0
        private void Update()
        {
            //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);
                Drawables[request.Name] = new TextureDrawable(texture);

                if (!IsIngameImage(request.Name))
                {
                    DrawablesList.Add(Drawables[request.Name]);
                }
                else
                {
                    InGameDrawablesList.Add(Drawables[request.Name]);
                }
            }
        }
コード例 #2
0
        private void UpdateDrawableTexture(string imageName, int x, int y)
        {
            TextureDrawable drawable = Drawables[imageName];

            drawable.X = x;
            drawable.Y = y;

            lock (SyncObj)
                TextureDictionary[imageName].Apply(false);

            if (ReorderDrawablesOnUpdate)
            {
                if (!IsIngameImage(imageName))
                {
                    //TODO: Avoid shifting cost.
                    //Remove from the list and then re-add
                    //so that freshly updated textures are forced on top.
                    DrawablesList.Remove(drawable);
                    DrawablesList.Add(drawable);
                }
                else
                {
                    //TODO: Avoid shifting cost.
                    //Remove from the list and then re-add
                    //so that freshly updated textures are forced on top.
                    InGameDrawablesList.Remove(drawable);
                    InGameDrawablesList.Add(drawable);
                }
            }
        }
コード例 #3
0
        public void DrawImageToScreen(string imageName, int x, int y)
        {
            DrawQueue.Enqueue(() =>
            {
                Drawables[imageName].X = x;
                Drawables[imageName].Y = y;

                lock (SyncObj)
                    TextureDictionary[imageName].Apply(false);

                if (!IsIngameImage(imageName))
                {
                    //TODO: Avoid shifting cost.
                    //Remove from the list and then re-add
                    //so that freshly updated textures are forced on top.
                    DrawablesList.Remove(Drawables[imageName]);
                    DrawablesList.Add(Drawables[imageName]);
                }
                else
                {
                    //TODO: Avoid shifting cost.
                    //Remove from the list and then re-add
                    //so that freshly updated textures are forced on top.
                    InGameDrawablesList.Remove(Drawables[imageName]);
                    InGameDrawablesList.Add(Drawables[imageName]);
                }
            });
        }
コード例 #4
0
        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]);
                }
            }
        }