105 lines
3.0 KiB
C#
105 lines
3.0 KiB
C#
using System;
|
|
using Manager;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
// Token: 0x02000186 RID: 390
|
|
[RequireComponent(typeof(CustomGraphic))]
|
|
public class MeshButton : Button, ICanvasRaycastFilter
|
|
{
|
|
// Token: 0x17000158 RID: 344
|
|
// (get) Token: 0x06000DD7 RID: 3543 RVA: 0x000416D2 File Offset: 0x000408D2
|
|
public InputManager.TouchPanelArea GetTouchPanelArea
|
|
{
|
|
get
|
|
{
|
|
return this.touchArea;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000DD8 RID: 3544 RVA: 0x000416DC File Offset: 0x000408DC
|
|
protected override void Awake()
|
|
{
|
|
this.touchArea = (InputManager.TouchPanelArea)Enum.Parse(typeof(InputManager.TouchPanelArea), base.name);
|
|
CustomGraphic customGraphic = base.targetGraphic as CustomGraphic;
|
|
this.vertexArray = new Vector2[customGraphic.vertex.Count];
|
|
for (int i = 0; i < customGraphic.vertex.Count; i++)
|
|
{
|
|
this.vertexArray[i] = RectTransformUtility.WorldToScreenPoint(Camera.main, new Vector2(base.transform.position.x + customGraphic.vertex[i].x, base.transform.position.y + customGraphic.vertex[i].y));
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000DD9 RID: 3545 RVA: 0x000417A5 File Offset: 0x000409A5
|
|
private void Update()
|
|
{
|
|
this.isMouseButton = DebugInput.GetMouseButton(0);
|
|
}
|
|
|
|
// Token: 0x06000DDA RID: 3546 RVA: 0x000417B3 File Offset: 0x000409B3
|
|
public void SetTouchCallback(Action<InputManager.TouchPanelArea> OnTouchDown, Action<InputManager.TouchPanelArea> OnTouch)
|
|
{
|
|
this.onTouchEvent = OnTouch;
|
|
this.onTouchDownEvent = OnTouchDown;
|
|
}
|
|
|
|
// Token: 0x06000DDB RID: 3547 RVA: 0x000417C4 File Offset: 0x000409C4
|
|
public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
|
|
{
|
|
bool flag = this.IsPointInPolygon(this.vertexArray, sp);
|
|
if (flag && DebugInput.GetMouseButtonDown(0))
|
|
{
|
|
this.onTouchDownEvent(this.touchArea);
|
|
base.onClick.Invoke();
|
|
}
|
|
else if (flag && this.isMouseButton)
|
|
{
|
|
this.onTouchEvent(this.touchArea);
|
|
base.onClick.Invoke();
|
|
}
|
|
return flag && this.isMouseButton;
|
|
}
|
|
|
|
// Token: 0x06000DDC RID: 3548 RVA: 0x0004183A File Offset: 0x00040A3A
|
|
public bool IsPointInPolygon(Vector2 point)
|
|
{
|
|
return this.IsPointInPolygon(this.vertexArray, point);
|
|
}
|
|
|
|
// Token: 0x06000DDD RID: 3549 RVA: 0x0004184C File Offset: 0x00040A4C
|
|
private bool IsPointInPolygon(Vector2[] polygon, Vector2 point)
|
|
{
|
|
int num = polygon.Length;
|
|
bool flag = false;
|
|
float x = point.x;
|
|
float y = point.y;
|
|
Vector2 vector = polygon[num - 1];
|
|
float num2 = vector.x;
|
|
float num3 = vector.y;
|
|
for (int i = 0; i < polygon.Length; i++)
|
|
{
|
|
float num4 = num2;
|
|
float num5 = num3;
|
|
Vector2 vector2 = polygon[i];
|
|
num2 = vector2.x;
|
|
num3 = vector2.y;
|
|
flag ^= ((num3 > y) ^ (num5 > y)) && x - num2 < (y - num3) * (num4 - num2) / (num5 - num3);
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
// Token: 0x04000A98 RID: 2712
|
|
private bool isMouseButton;
|
|
|
|
// Token: 0x04000A99 RID: 2713
|
|
private Vector2[] vertexArray;
|
|
|
|
// Token: 0x04000A9A RID: 2714
|
|
private InputManager.TouchPanelArea touchArea;
|
|
|
|
// Token: 0x04000A9B RID: 2715
|
|
private Action<InputManager.TouchPanelArea> onTouchEvent;
|
|
|
|
// Token: 0x04000A9C RID: 2716
|
|
private Action<InputManager.TouchPanelArea> onTouchDownEvent;
|
|
}
|