Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TMP_SelectionCaret.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace TMPro
  4. {
  5. /// <summary>
  6. /// A simple component that can be added to a newly created object where inheriting from MaskableGraphic is needed.
  7. /// </summary>
  8. [RequireComponent(typeof(CanvasRenderer))]
  9. public class TMP_SelectionCaret : MaskableGraphic
  10. {
  11. /// <summary>
  12. /// Override to Cull function of MaskableGraphic to prevent Culling.
  13. /// </summary>
  14. /// <param name="clipRect"></param>
  15. /// <param name="validRect"></param>
  16. public override void Cull(Rect clipRect, bool validRect)
  17. {
  18. //Debug.Log("***** Cull (" + clipRect + ") Valid Rect: " + validRect + " Cull: " + canvasRenderer.cull + " *****");
  19. if (validRect)
  20. {
  21. canvasRenderer.cull = false;
  22. CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this);
  23. return;
  24. }
  25. base.Cull(clipRect, validRect);
  26. }
  27. protected override void UpdateGeometry()
  28. {
  29. // Function overridden as Caret and text Selection Highlight is controlled by the Input Field.
  30. }
  31. }
  32. }