CursorRendererBase.cs 728 B

12345678910111213141516171819202122232425262728293031
  1. using System.Collections;
  2. using UnityEngine;
  3. namespace ZenFulcrum.EmbeddedBrowser {
  4. /// <summary>
  5. /// These classes handle rendering the cursor of a browser.
  6. ///
  7. /// Using one is optional. You can opt not to show a cursor.
  8. /// </summary>
  9. [RequireComponent(typeof(PointerUIBase))]
  10. abstract public class CursorRendererBase : MonoBehaviour {
  11. protected BrowserCursor cursor;
  12. public virtual void OnEnable() {
  13. StartCoroutine(Setup());
  14. }
  15. private IEnumerator Setup() {
  16. if (cursor != null) yield break;
  17. yield return null;//wait a frame to let the browser UI get set up
  18. cursor = GetComponent<Browser>().UIHandler.BrowserCursor;
  19. cursor.cursorChange += CursorChange;
  20. }
  21. protected abstract void CursorChange();
  22. }
  23. }