using Fort23.UTool; using UnityEngine; using UnityEngine.UI; namespace Fort23.Mono { public class MyGuideMask : MonoBehaviour, ICanvasRaycastFilter { public Image _Mask; //?????? private Material _materia; public GameObject target; private void Awake() { // _materia = _Mask.material; // RectTransform rectTransform = target.GetComponent(); // CreateCircleRectangleMask(rectTransform.anchoredPosition, rectTransform.sizeDelta, 2); } /// /// ?????????????? /// /// ???ε????λ?? /// ?????λ?? /// ?????λ?? public void CreateCircleRectangleMask(Vector2 pos, Vector2 widthAndHeight, float raid) { _materia.SetFloat("_MaskType", 2f); _materia.SetVector("_Origin", new Vector4(pos.x, pos.y, widthAndHeight.x, widthAndHeight.y)); _materia.SetFloat("_Raid", raid); } /// /// ???????ε?????? /// /// ????????????? /// ???ο?? public void CreateRectangleMask(Vector2 pos, Vector2 widthAndHeight, float raid) { _materia.SetFloat("_MaskType", 1f); _materia.SetVector("_Origin", new Vector4(pos.x, pos.y, widthAndHeight.x, widthAndHeight.y)); } /// /// ???????ε?????? /// /// ?????????????? /// ?????? /// С???????????? /// С???? public void CreateCircleMask(Vector3 pos, float rad, Vector3 pos1, float rad1) { _materia.SetFloat("_MaskType", 0f); _materia.SetVector("_Origin", new Vector4(pos.x, pos.y, rad, 0)); _materia.SetVector("_TopOri", new Vector4(pos1.x, pos1.y, rad1, 0)); } /// /// ?????????Mask??? /// /// ??? public void SetTargetImage(GameObject tg) { target = tg; } public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera) { //??????????????? if (target == null) { return true; } //?????Χ?????????? return !RectTransformUtility.RectangleContainsScreenPoint(target.GetComponent(), sp, eventCamera); } public void CustomPoint() { LogTool.Log("??????????"); } } }