CUI_RaycastToCanvas.cs 604 B

123456789101112131415161718192021222324252627
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace CurvedUI
  4. {
  5. public class CUI_RaycastToCanvas : MonoBehaviour
  6. {
  7. CurvedUISettings mySettings;
  8. // Use this for initialization
  9. void Start()
  10. {
  11. mySettings = GetComponentInParent<CurvedUISettings>();
  12. }
  13. // Update is called once per frame
  14. void Update()
  15. {
  16. Vector2 pos = Vector2.zero;
  17. mySettings.RaycastToCanvasSpace(Camera.main.ScreenPointToRay(Input.mousePosition), out pos);
  18. this.transform.localPosition = pos;
  19. }
  20. }
  21. }