CursorRendererOverlay.cs 705 B

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. namespace ZenFulcrum.EmbeddedBrowser {
  3. /// <summary>
  4. /// Renders a browser's cursor by rendering something in the center of the screen.
  5. /// </summary>
  6. public class CursorRendererOverlay : CursorRendererBase {
  7. [Tooltip("How large should we render the cursor?")]
  8. public float scale = .5f;
  9. protected override void CursorChange() {}
  10. public void OnGUI() {
  11. if (cursor == null) return;
  12. if (!cursor.HasMouse || !cursor.Texture) return;
  13. var tex = cursor.Texture;
  14. var pos = new Rect(Screen.width / 2f, Screen.height / 2f, tex.width * scale, tex.height * scale);
  15. pos.x -= cursor.Hotspot.x * scale;
  16. pos.y -= cursor.Hotspot.y * scale;
  17. GUI.DrawTexture(pos, tex);
  18. }
  19. }
  20. }