1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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<RectTransform>();
- // CreateCircleRectangleMask(rectTransform.anchoredPosition, rectTransform.sizeDelta, 2);
- }
- /// <summary>
- /// ??????????????
- /// </summary>
- /// <param name="pos">???ε????λ??</param>
- /// <param name="pos1">?????λ??</param>
- /// <param name="pos2">?????λ??</param>
- 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);
- }
- /// <summary>
- /// ???????ε??????
- /// </summary>
- /// <param name="pos">?????????????</param>
- /// <param name="widthAndHeight">???ο??</param>
- 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));
- }
- /// <summary>
- /// ???????ε??????
- /// </summary>
- /// <param name="pos">??????????????</param>
- /// <param name="rad">??????</param>
- /// <param name="pos1">С????????????</param>
- /// <param name="rad1">С????</param>
- 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));
- }
- /// <summary>
- /// ?????????Mask???
- /// </summary>
- /// <param name="tg">???</param>
- public void SetTargetImage(GameObject tg)
- {
- target = tg;
- }
- public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
- {
- //???????????????
- if (target == null)
- {
- return true;
- }
- //?????Χ??????????
- return !RectTransformUtility.RectangleContainsScreenPoint(target.GetComponent<RectTransform>(),
- sp, eventCamera);
- }
- public void CustomPoint()
- {
- LogTool.Log("??????????");
- }
- }
- }
|