private void UpdateCursor(bool updateSprite) { double perc = 0; if (Active) { if (updateSprite) { cursorState = (cursorState + 1) % (2 * CURSOR_STATES); } perc = cursorState % CURSOR_STATES; perc /= CURSOR_STATES; } for (int i = 0; i < 9; i++) { if (cursorSprites[i] == null) { return; } if (cursorSprites[i].Disposed) { return; } if (Active) { if (cursorState >= CURSOR_STATES) { cursorSprites[i].Opacity = (int)(perc * (255 - MIN_CURSOR_OPACITY) + MIN_CURSOR_OPACITY); } else { cursorSprites[i].Opacity = (int)((1 - perc) * (255 - MIN_CURSOR_OPACITY) + MIN_CURSOR_OPACITY); } cursorSprites[i].Opacity *= Opacity / 255; } else { cursorSprites[i].Opacity = Opacity; } if (i == (int)Sides.Center) { cursorSprites[i].Z = Z + 4; } else { cursorSprites[i].Z = Z + 5; } cursorSprites[i].Visible = Visible && Active; if (updateSprite) { cursorSprites[i].Update(); } } if (!CursorRect.Empty()) { Rect rect = new Rect(rX + CursorRect.X, rY + CursorRect.Y, CursorRect.Width, CursorRect.Height); if (rect.X < X) { rect.X = X; } if (rect.Y < Y) { rect.Y = Y; } if (rect.Right > Rect.Right) { rect.Width -= rect.Right - Rect.Right; } if (rect.Bottom > Rect.Bottom) { rect.Height -= rect.Bottom - Rect.Bottom; } UpdateFrameSprites(ref cursorSprites, rect, C_BORDER_WIDTH, C_BORDER_WIDTH); } }
private void SetUpCursorCanvas() { _cursorCanvas = CursorRect.GetComponent <Canvas>(); _cursorCanvas.enabled = Scheme.CanUseVirtualCursor; }