2024-07-30 17:38:24 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class FloatingJoystick : Joystick
|
|
|
|
|
{
|
|
|
|
|
public Image mImgBg;
|
|
|
|
|
public Image mImgHandle;
|
2024-08-07 18:23:55 +08:00
|
|
|
|
public Image mImgArrow;
|
2024-07-30 17:38:24 +08:00
|
|
|
|
|
|
|
|
|
public bool mIsMounseDown = false;
|
|
|
|
|
|
2024-08-07 18:23:55 +08:00
|
|
|
|
public static Color ShowColor = new Color(1F, 1f, 1F, 0.7f);
|
|
|
|
|
public static Color HideColor = new Color(1F, 1f, 1F, 0.3f);
|
2024-07-30 17:38:24 +08:00
|
|
|
|
|
|
|
|
|
//一次新的摇杆移动
|
|
|
|
|
public static bool bNewTouchWithSkill = false;
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Start()
|
|
|
|
|
{
|
|
|
|
|
base.Start();
|
|
|
|
|
mImgBg = background.transform.GetComponent<Image>();
|
|
|
|
|
mImgHandle = background.transform.Find("Handle").GetComponent<Image>();
|
|
|
|
|
mArrow = transform.Find("Background/Arrow").GetComponent<RectTransform>();
|
2024-08-07 18:23:55 +08:00
|
|
|
|
mImgArrow = transform.Find("Background/Arrow/imgArrow").GetComponent<Image>();
|
2024-07-30 17:38:24 +08:00
|
|
|
|
mArrow.gameObject.SetActive(false);
|
|
|
|
|
//background.gameObject.SetActive(false);
|
|
|
|
|
background.gameObject.SetActive(true);
|
|
|
|
|
background.transform.localPosition = new Vector3(256f, 256f, 0);
|
|
|
|
|
mImgBg.color = HideColor;
|
|
|
|
|
mImgHandle.color = HideColor;
|
2024-08-07 18:23:55 +08:00
|
|
|
|
mImgArrow.color = HideColor;
|
2024-07-30 17:38:24 +08:00
|
|
|
|
mIsMounseDown = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnPointerDown(PointerEventData eventData)
|
|
|
|
|
{
|
2024-08-07 18:23:55 +08:00
|
|
|
|
//background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
2024-07-30 17:38:24 +08:00
|
|
|
|
//background.gameObject.SetActive(true);
|
|
|
|
|
mImgBg.color = ShowColor;
|
|
|
|
|
mImgHandle.color = ShowColor;
|
2024-08-07 18:23:55 +08:00
|
|
|
|
mImgArrow.color = ShowColor;
|
2024-07-30 17:38:24 +08:00
|
|
|
|
mIsMounseDown = true;
|
|
|
|
|
base.OnPointerDown(eventData);
|
|
|
|
|
bNewTouchWithSkill = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnPointerUp(PointerEventData eventData)
|
|
|
|
|
{
|
|
|
|
|
//background.gameObject.SetActive(false);
|
|
|
|
|
PointerUp();
|
|
|
|
|
bNewTouchWithSkill = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PointerUp()
|
|
|
|
|
{
|
|
|
|
|
if (background == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
background.transform.localPosition = new Vector3(256f, 256f, 0);
|
|
|
|
|
mImgBg.color = HideColor;
|
|
|
|
|
mImgHandle.color = HideColor;
|
|
|
|
|
mIsMounseDown = false;
|
|
|
|
|
base.PointerUp();
|
|
|
|
|
}
|
|
|
|
|
}
|