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.
121 lines
3.7 KiB
121 lines
3.7 KiB
using UnityEngine; |
|
using System.Collections; |
|
using UnityEngine.UI; |
|
|
|
using System.Collections.Generic; |
|
using UnityEngine.Serialization; |
|
|
|
namespace UnityEngine.UI |
|
{ |
|
public class GuideHighlightMask : MaskableGraphic,UnityEngine.ICanvasRaycastFilter |
|
{ |
|
public RectTransform arrow; |
|
public Vector2 center = Vector2.zero; |
|
public Vector2 size = new Vector2(100, 100); |
|
public void DoUpdate() |
|
{ |
|
if(arrow&¢er!=arrow.anchoredPosition||size!=arrow.sizeDelta) |
|
{ |
|
this.center = arrow.anchoredPosition; |
|
this.size = arrow.sizeDelta; |
|
SetAllDirty(); |
|
} |
|
} |
|
public bool IsRaycastLocationValid(Vector2 sp,Camera eventCamera) |
|
{ |
|
return !RectTransformUtility.RectangleContainsScreenPoint(arrow, sp, eventCamera); |
|
} |
|
|
|
protected override void OnFillVBO(List<UIVertex> vbo) |
|
{ |
|
Vector4 outer = new Vector4(-rectTransform.pivot.x * rectTransform.rect.width, |
|
-rectTransform.pivot.y * rectTransform.rect.height, |
|
(1 - rectTransform.pivot.x) * rectTransform.rect.width, |
|
(1 - rectTransform.pivot.y) * rectTransform.rect.height); |
|
Vector4 inner = new Vector4(center.x - size.x / 2, |
|
center.y - size.y / 2, |
|
center.x + size.x * 0.5f, |
|
center.y + size.y * 0.5f); |
|
vbo.Clear(); |
|
var vert = UIVertex.simpleVert; |
|
//left |
|
vert.position = new Vector2(outer.x,outer.y); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.x, outer.w); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.x, outer.w); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.x, outer.y); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
//top |
|
vert.position = new Vector2(outer.x, outer.w); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.x, outer.w); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.z, outer.w); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.z, outer.w); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
//right |
|
vert.position = new Vector2(outer.z, outer.y); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.z, outer.w); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.z, outer.w); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.z, outer.y); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
//bottom |
|
vert.position = new Vector2(outer.x, outer.y); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.x, outer.y); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.z, outer.y); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
vert.position = new Vector2(outer.z, outer.y); |
|
vert.color = color; |
|
vbo.Add(vert); |
|
|
|
} |
|
public void Update() |
|
{ |
|
DoUpdate(); |
|
} |
|
void Start() |
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
} |
|
|
|
|
|
|