【UI】重构战场UI点击、滑动事件

main
chenyuqi 2024-09-04 16:02:38 +08:00
parent ba48bc7114
commit c082d16b50
22 changed files with 760 additions and 113 deletions

View File

@ -2488,6 +2488,7 @@ GameObject:
- component: {fileID: 3256400772162238298}
- component: {fileID: 1034534244146385000}
- component: {fileID: 2449883932285482295}
- component: {fileID: 2328575895974818237}
m_Layer: 5
m_Name: Bg
m_TagString: Untagged
@ -2536,7 +2537,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 0
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
@ -2552,6 +2553,18 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &2328575895974818237
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6312497754087081663}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 92a780f4c13b41a488ae0e00b8b05bff, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &6489548880288932210
GameObject:
m_ObjectHideFlags: 0

View File

@ -7024,7 +7024,7 @@ MonoBehaviour:
GameObject_HP: {fileID: 259909095321089936}
Content: {fileID: 2840963628902164}
Text_Number: {fileID: 5026260227087812372}
ButtonEx_CharacterPicRect: {fileID: 5685959052515926676}
ButtonEx_CharacterPicRect: {fileID: 8872568503622443425}
--- !u!225 &2430238170518010662
CanvasGroup:
m_ObjectHideFlags: 0
@ -9201,7 +9201,7 @@ GameObject:
- component: {fileID: 3920338427050065878}
- component: {fileID: 9126152930388242892}
- component: {fileID: 5978193718012480300}
- component: {fileID: 5685959052515926676}
- component: {fileID: 8872568503622443425}
m_Layer: 5
m_Name: Button_CharacterPicRect
m_TagString: Untagged
@ -9295,7 +9295,7 @@ Animator:
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!114 &5685959052515926676
--- !u!114 &8872568503622443425
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -9304,41 +9304,9 @@ MonoBehaviour:
m_GameObject: {fileID: 8214106066121177496}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 85105a9b5398447dbe9c87add22e5938, type: 3}
m_Script: {fileID: 11500000, guid: 045ca730a13148b39d05b5b8b5f147f1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 5967604298863751600}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &8342876886178415752
GameObject:
m_ObjectHideFlags: 0

View File

@ -124,13 +124,14 @@ GameObject:
- component: {fileID: 4917783600122570285}
- component: {fileID: 5056986200012590518}
- component: {fileID: 8912371064777793614}
- component: {fileID: 3194098173158077470}
m_Layer: 5
m_Name: Button_CMSkillPress0
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1929576929672572709
RectTransform:
m_ObjectHideFlags: 0
@ -197,7 +198,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 434493684896517382}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 85105a9b5398447dbe9c87add22e5938, type: 3}
m_Name:
@ -234,6 +235,18 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &3194098173158077470
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 434493684896517382}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 92a780f4c13b41a488ae0e00b8b05bff, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &787517095453631874
GameObject:
m_ObjectHideFlags: 0
@ -522,7 +535,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
Image_CMSkillNormal: {fileID: 1624282477261039562}
Image_SkillProgress: {fileID: 6400541329633051642}
Button_CMSkillPress: {fileID: 6044799069448290319}
Button_CMSkillPress: {fileID: 636806674413692010}
Image_CMSkillReady: {fileID: 8564590078531436457}
--- !u!1 &2023270126729846489
GameObject:
@ -801,7 +814,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
Image_CMSkillNormal: {fileID: 4133531488485739680}
Image_SkillProgress: {fileID: 5298022622881365334}
Button_CMSkillPress: {fileID: 1904385389556834815}
Button_CMSkillPress: {fileID: 5971225584053796617}
Image_CMSkillReady: {fileID: 7495518089732989502}
--- !u!1 &3928331901051939328
GameObject:
@ -2611,7 +2624,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
Image_CMSkillNormal: {fileID: 5913976849735430340}
Image_SkillProgress: {fileID: 2877948175438296221}
Button_CMSkillPress: {fileID: 8912371064777793614}
Button_CMSkillPress: {fileID: 3194098173158077470}
Image_CMSkillReady: {fileID: 2743784217664668732}
--- !u!1 &8129260256390057412
GameObject:
@ -2898,13 +2911,14 @@ GameObject:
- component: {fileID: 1331008028907460037}
- component: {fileID: 6050765481580646436}
- component: {fileID: 1904385389556834815}
- component: {fileID: 5971225584053796617}
m_Layer: 5
m_Name: Button_CMSkillPress2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &5136432199240189714
RectTransform:
m_ObjectHideFlags: 0
@ -2971,7 +2985,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8309420679099269606}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 85105a9b5398447dbe9c87add22e5938, type: 3}
m_Name:
@ -3008,6 +3022,18 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &5971225584053796617
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8309420679099269606}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 92a780f4c13b41a488ae0e00b8b05bff, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &8555378348700654059
GameObject:
m_ObjectHideFlags: 0
@ -3020,13 +3046,14 @@ GameObject:
- component: {fileID: 6065257386196078308}
- component: {fileID: 7177734568258913237}
- component: {fileID: 6044799069448290319}
- component: {fileID: 636806674413692010}
m_Layer: 5
m_Name: Button_CMSkill_Press1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &4353966992364800606
RectTransform:
m_ObjectHideFlags: 0
@ -3093,7 +3120,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8555378348700654059}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 85105a9b5398447dbe9c87add22e5938, type: 3}
m_Name:
@ -3130,6 +3157,18 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &636806674413692010
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8555378348700654059}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 92a780f4c13b41a488ae0e00b8b05bff, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &8613540382860965303
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,4 +1,6 @@
//流式播放的音频管理器
using System;
using System.Collections.Generic;
using System.Linq;
using CriWare;
@ -6,6 +8,7 @@ using Framework;
using PhxhSDK;
using UnityEngine;
using AudioType = PhxhSDK.AudioBase.AudioType;
using Object = UnityEngine.Object;
public class AudioCriManager: Singlenton<AudioCriManager>, IStart, IInitable, IUpdatable, IAudioPlay
{
@ -401,7 +404,14 @@ public class AudioCriManager: Singlenton<AudioCriManager>, IStart, IInitable, IU
{
return -1;
}
CriAtom.AddCueSheet(cueSheetName, acbPath, awbPath, null);
var cueSheet = CriAtom.AddCueSheet(cueSheetName, acbPath, awbPath, null);
}
var cueInfoList = CriAtom.GetCueSheetInternal(cueSheetName).acb.GetCueInfoList();
var cueInfo = Array.Find(cueInfoList, (cue) => cue.name == key );
if (cueInfo.name == null)
{
DebugUtil.LogWarning($"Can not Find Criware Key:{key}");
return -1;
}
}
@ -447,7 +457,14 @@ public class AudioCriManager: Singlenton<AudioCriManager>, IStart, IInitable, IU
{
return -1;
}
CriAtom.AddCueSheet(cueSheetName, acbPath, awbPath, null);
var cueSheet = CriAtom.AddCueSheet(cueSheetName, acbPath, awbPath, null);
}
var cueInfoList = CriAtom.GetCueSheetInternal(cueSheetName).acb.GetCueInfoList();
var cueInfo = Array.Find(cueInfoList, (cue) => cue.name == key );
if (cueInfo.name == null)
{
DebugUtil.LogWarning($"Can not Find Criware Key:{key}");
return -1;
}
}

View File

@ -56,6 +56,8 @@
FightCmpTimelinePause,
Level_OnClick,
Level_OnDrag,
//level Fight UI
LevelFightStartChange,
LevelFightUIStateChange,
@ -75,6 +77,9 @@
UI_START_USE_SKILL,
UI_END_USE_SKILL,
UI_FIGHT_SCENE_SHOW,
UI_FIGHT_SCENE_HIDE,
// 剧情事件
STORY_CLICK_SCREEN,
STORY_OPEN_CHOICE_UI,

View File

@ -0,0 +1,247 @@
using System;
using System.Collections.Generic;
using CriWare;
using Sirenix.Utilities;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem.UI;
using UnityEngine.UIElements;
public class ButtonEx: MonoBehaviour, IPointerUpHandler, IPointerDownHandler, IDragHandler, IBeginDragHandler, IEndDragHandler
{
private bool _isPressed;
private bool _isLastFramePressed;
private float _pressedTime;
private const float MinDelta = 0.0001f;
private const float MinLongPressTime = 0.35f;
private const float MinUpDelta = 1f;
private List<PointerEventData> _pointerEventDatas = new();
private PointerEventData _curPointerEventData;
#region 继承滑动、按下抬起
public delegate void BeginDrag(PointerEventData eventData);
public delegate void OnDragging(PointerEventData eventData);
public delegate void EndDrag(PointerEventData eventData);
public delegate void OnPointUp(PointerEventData eventData);
public delegate void OnPointDown(PointerEventData eventData);
public BeginDrag beginDrag;
public OnDragging onDragging;
public EndDrag endDrag;
public OnPointUp onPointUp;
public OnPointDown onPointDown;
public void OnPointerUp(PointerEventData eventData)
{
// if (eventData.pointerId >= 0)
// {
// DebugUtil.LogError("OnPointerUp eventData.pointerId = " + eventData.pointerId);
// return;
// }
if (_pressedTime < MinLongPressTime)
{
if (_bOnClick)
{
onClick?.Invoke();
_bOnClick = false;
}
}
_curPointerEventData = null;
_isPressed = false;
_bLongPress = true;
_bUpDrag = true;
onPointUp?.Invoke(eventData);
}
public void OnPointerDown(PointerEventData eventData)
{
// if (eventData.pointerId >= 0)
// {
// DebugUtil.LogError("OnPointerUp eventData.pointerId = " + eventData.pointerId);
// return;
// }
_curPointerEventData = eventData;
_isPressed = true;
_bLongPress = true;
_bUpDrag = true;
_startPos = eventData.pressPosition;
onPointDown?.Invoke(eventData);
}
public void OnDrag(PointerEventData eventData)
{
if (eventData.pointerId < 0)
{
_curPointerEventData = eventData;
}
onDragging?.Invoke(eventData);
}
public void OnBeginDrag(PointerEventData eventData)
{
if (eventData.pointerId < 0)
{
_curPointerEventData = eventData;
}
beginDrag?.Invoke(eventData);
}
public void OnEndDrag(PointerEventData eventData)
{
if (eventData.pointerId < 0)
{
_curPointerEventData = eventData;
}
endDrag?.Invoke(eventData);
}
public void AddPointerUp(Action<PointerEventData> action)
{
onPointUp += (eventData) =>
{
action?.Invoke(eventData);
};
}
public void AddPointerDown(Action<PointerEventData> action)
{
onPointDown += (eventData) =>
{
action?.Invoke(eventData);
};
}
public void AddBeginDrag(Action<PointerEventData> action)
{
beginDrag += (eventData) =>
{
action?.Invoke(eventData);
};
}
public void AddOnDrag(Action<PointerEventData> action)
{
onDragging += (eventData) =>
{
action?.Invoke(eventData);
};
}
public void AddEndDrag(Action<PointerEventData> action)
{
endDrag += (eventData) =>
{
action?.Invoke(eventData);
};
}
#endregion
#region 扩展上滑、长按
private bool _bUpDrag;
private bool _bLongPress;
private bool _bOnClick;
public delegate void OnUpDrag();
public delegate void OnLongPress();
public delegate void OnClick();
public OnUpDrag onUpDrag;
public OnLongPress onLongPress;
public OnClick onClick;
private Vector2 _startPos;
private Vector2 _curPos;
public void AddLongPress(Action action)
{
onLongPress += () =>
{
action?.Invoke();
};
}
public void AddUpDrag(Action action)
{
onUpDrag += () =>
{
action?.Invoke();
};
}
public void AddUpDrag<T>(Action<T> action, T param)
{
onUpDrag += () =>
{
action?.Invoke(param);
};
}
#endregion
private void Update()
{
if (!_isPressed)
{
_bOnClick = false;
_isLastFramePressed = false;
_pressedTime = 0f;
return;
}
if (_isPressed)
{
_curPos = _curPointerEventData.position;
//长按
if (_bLongPress)
{
var disSqr = (_curPos - _startPos).sqrMagnitude;
if (disSqr > MinDelta)
{
_bLongPress = false;
_bOnClick = false;
}
else
{
if (_pressedTime > MinLongPressTime)
{
onLongPress?.Invoke();
_bLongPress = false;
}
}
}
//上滑
if (_bUpDrag)
{
var disSqrY = Mathf.Sqrt(_curPos.y - _startPos.y);
var disSqrX = Mathf.Sqrt(_curPos.x - _startPos.x);
if (disSqrY > MinUpDelta && disSqrX < disSqrY / 2)
{
onUpDrag?.Invoke();
_bUpDrag = false;
}
}
_pressedTime += Time.deltaTime;
if (!_isLastFramePressed)
{
_isLastFramePressed = true;
}
}
}
public void RemoveAll()
{
}
private void OnDestroy()
{
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 92a780f4c13b41a488ae0e00b8b05bff
timeCreated: 1725341705

View File

@ -0,0 +1,183 @@
using System;
using Framework;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class ButtonUpDrag: MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
private bool _isPressed;
private bool _isLastFramePressed;
private float _pressedTime;
private const float MinDelta = 0.01f;
private const float MinLongPressTime = 0.35f;
private const float MinUpDelta = 2f;
private float _maxHorDelta = 0f;
private bool _bUpDrag;
private bool _bLongPress;
private bool _bOnClick;
public delegate void OnUpDrag();
public delegate void OnLongPress();
public delegate void OnClick();
public delegate void OnPointUp();
public delegate void OnPointDown();
public OnPointUp onPointUp;
public OnPointDown onPointDown;
public OnUpDrag onUpDrag;
public OnLongPress onLongPress;
public OnClick onClick;
private Vector2 _startPos;
private Vector2 _curPos;
public void AddPointerUp(Action action)
{
onPointUp += () =>
{
action?.Invoke();
};
}
public void AddPointerDown(Action action)
{
onPointDown += () =>
{
action?.Invoke();
};
}
public void AddLongPress(Action action)
{
onLongPress += () =>
{
action?.Invoke();
};
}
public void AddUpDrag(Action action)
{
onUpDrag += () =>
{
action?.Invoke();
};
}
public void AddUpDrag<T>(Action<T> action, T param)
{
onUpDrag += () =>
{
action?.Invoke(param);
};
}
public void OnPointerDown(PointerEventData eventData)
{
_isPressed = true;
_bLongPress = true;
_bUpDrag = true;
_startPos = eventData.pressPosition;
}
public void OnPointerUp(PointerEventData eventData)
{
// _isPressed = false;
// _bLongPress = true;
// _bUpDrag = true;
}
private void Awake()
{
InputManager.Instance.OnFingerUpUI += _OnPutUp;
InputManager.Instance.OnFingerUp += _OnPutUp;
}
private void OnDestroy()
{
if (InputManager.Instance)
{
InputManager.Instance.OnFingerUpUI -= _OnPutUp;
InputManager.Instance.OnFingerUp -= _OnPutUp;
}
}
private void Update()
{
if (!_isPressed)
{
_bOnClick = false;
_isLastFramePressed = false;
_pressedTime = 0f;
_maxHorDelta = 0f;
return;
}
if (_isPressed)
{
_curPos = InputManager.Instance.GetTouchPosition();
//长按
if (_bLongPress)
{
var disSqr = (_curPos - _startPos).sqrMagnitude;
if (disSqr > MinDelta)
{
_bLongPress = false;
_bOnClick = false;
}
else
{
if (_pressedTime > MinLongPressTime)
{
onLongPress?.Invoke();
_bLongPress = false;
}
}
}
//上滑
if (_bUpDrag)
{
var disSqrY = Mathf.Sqrt(_curPos.y - _startPos.y);
var disSqrX = Mathf.Sqrt(_curPos.x - _startPos.x);
if (_maxHorDelta < disSqrX)
{
_maxHorDelta = disSqrX;
}
if (_maxHorDelta < MinUpDelta)
{
if (disSqrY > MinUpDelta && disSqrX < disSqrY)
{
onUpDrag.Invoke();
_bUpDrag = false;
}
}
}
_pressedTime += Time.deltaTime;
if (!_isLastFramePressed)
{
_isLastFramePressed = true;
}
}
}
private void _OnPutUp(Vector2 pos)
{
if (_isPressed)
{
_isPressed = false;
_bLongPress = true;
_bUpDrag = true;
}
}
public void RemoveAll()
{
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 045ca730a13148b39d05b5b8b5f147f1
timeCreated: 1725425123

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,20 @@ using Cysharp.Threading.Tasks;
public partial class SROptions
{
[Category("UI"), DisplayName("开启战场UITrigger")]
public static bool Debug_UITriggerRun
{
get
{
return _bUITriggerRun;
}
set
{
_bUITriggerRun = value;
}
}
private static bool _bUITriggerRun = true;
[Category("UI")]
[DisplayName("展示UI堆栈")]
public void ShowUIStack()

View File

@ -1,3 +1,4 @@
using System;
using Framework;
using Gameplay.Guide;
using TGS;
@ -16,7 +17,8 @@ namespace Gameplay.Level
public void OnEnter()
{
InputManager.Instance.OnClick += _OnClick;
//InputManager.Instance.OnClick += _OnClick;
EventManager.Instance.Register(EventManager.EventName.Level_OnClick, (Action<Vector2>) _OnClick);
_OnEnter();
}
@ -30,7 +32,8 @@ namespace Gameplay.Level
{
_OnExit();
// _level.Map.TerrainGridSystem.OnCellClick -= _OnCellClick;
InputManager.Instance.OnClick -= _OnClick;
//InputManager.Instance.OnClick -= _OnClick;
EventManager.Instance.Unregister(EventManager.EventName.Level_OnClick, (Action<Vector2>) _OnClick);
}
protected abstract void _OnEnter();

View File

@ -904,6 +904,16 @@ public partial class TeamManager
{
return m_allCharactersMap.ContainsKey(uid);
}
public bool CheckIsOnCancel()
{
if (UIManager.Instance.GetOpenedWindowByPath(UINameConst.UIFightPoster) is UIPosterAndSkillInfoController window)
{
return window.CheckIsInCancel();
}
return false;
}
}
//测试用,暂存一个载具信息类

View File

@ -471,9 +471,10 @@ public class UIHeadItemNode : UINode
}
public virtual void RemoveAllClickListener(UIButtonEx button)
public virtual void RemoveAllClickListener(ButtonUpDrag button)
{
button.RemoveAllListener();
//button.RemoveAllListener();
button.RemoveAll();
}
public virtual void RemoveClickListener()

View File

@ -37,7 +37,7 @@ public class UIHerosHeadItemNode : UIHeadItemNodeBase
public GameObject Content;
public TMP_Text Text_Number;
public UIButtonEx ButtonEx_CharacterPicRect;
public ButtonUpDrag ButtonEx_CharacterPicRect;
private bool isOnFight; //是否是战斗上阵Item
private bool isSkillReady; //技能是否已准备
@ -138,18 +138,18 @@ public class UIHerosHeadItemNode : UIHeadItemNodeBase
});
}
public override void BindItemLongPress<T>(Action<T> action,
T param)
{
ButtonEx_CharacterPicRect.AddLongPressListener(() =>
{
action?.Invoke(param);
});
}
// public override void BindItemLongPress<T>(Action<T> action,
// T param)
// {
// ButtonEx_CharacterPicRect.AddLongPressListener(() =>
// {
// action?.Invoke(param);
// });
// }
public override void BindItemPointerUp(Action action)
{
ButtonEx_CharacterPicRect.AddPointUpListener(() =>
ButtonEx_CharacterPicRect.AddPointerUp(() =>
{
action?.Invoke();
});
@ -158,7 +158,7 @@ public class UIHerosHeadItemNode : UIHeadItemNodeBase
public override void BindItemUpDrag<T>(Action<T> action,
T param)
{
ButtonEx_CharacterPicRect.AddUpDragListener(() =>
ButtonEx_CharacterPicRect.AddUpDrag(() =>
{
action?.Invoke(param);
});
@ -174,28 +174,28 @@ public class UIHerosHeadItemNode : UIHeadItemNodeBase
});
}
public override void BindItemStartDrag<T>(Action<T> action, T param)
{
ButtonEx_CharacterPicRect.AddStartDragListener(() =>
{
action?.Invoke(param);
});
}
public override void BindItemOnDrag<T>(Action<T> action, T param)
{
ButtonEx_CharacterPicRect.AddOnDragListener(() =>
{
action?.Invoke(param);
});
}
// public override void BindItemStartDrag<T>(Action<T> action, T param)
// {
// ButtonEx_CharacterPicRect.AddStartDragListener(() =>
// {
// action?.Invoke(param);
// });
// }
// public override void BindItemOnDrag<T>(Action<T> action, T param)
// {
// ButtonEx_CharacterPicRect.AddOnDragListener(() =>
// {
// action?.Invoke(param);
// });
// }
public override void BindItemEndDrag<T>(Action<T> action, T param)
{
ButtonEx_CharacterPicRect.AddEndDragListener(() =>
{
action?.Invoke(param);
});
}
// public override void BindItemEndDrag<T>(Action<T> action, T param)
// {
// ButtonEx_CharacterPicRect.AddEndDragListener(() =>
// {
// action?.Invoke(param);
// });
// }
public override void RemoveClickListener()
{

View File

@ -197,4 +197,13 @@ public class UIPosterAndSkillInfoController : UIWindow
EventManager.Instance.Send(EventManager.EventName.UICancelSkillPut);
}
}
public bool CheckIsInCancel()
{
var rectTrans = Button_SkillInfoBg.GetComponent<RectTransform>();
bool isCancel = RectTransformUtility.RectangleContainsScreenPoint(rectTrans,
InputManager.Instance.GetTouchPosition(),
CameraManager.Instance.UICamera);
return isCancel;
}
}

View File

@ -163,20 +163,22 @@ public class UITeamFightController : UIWindow
EventManager.Instance.Register(EventManager.EventName.UI_SKILL_CANCEL, _OnSkillPauseEnd);
EventManager.Instance.Register(EventManager.EventName.UICancelSkillPut, _OnSkillCancelEvent);
InputManager.Instance.OnFingerMove += OnItemDrag;
//InputManager.Instance.OnFingerMove += OnItemDrag;
InputManager.Instance.OnFingerMoveUI += OnItemDrag;
InputManager.Instance.OnFingerUp += OnItemEndDrag;
InputManager.Instance.OnFingerUp += OnPointerUpFightSkill;
// InputManager.Instance.OnFingerUp += OnItemEndDrag;
// InputManager.Instance.OnFingerUp += OnPointerUpFightSkill;
InputManager.Instance.OnFingerUpUI += OnPointerUpFightSkill;
InputManager.Instance.OnFingerUpUI += OnItemEndDrag;
}
private void _UnRegisterEvents()
{
InputManager.Instance.OnFingerMove -= OnItemDrag;
InputManager.Instance.OnFingerUp -= OnItemEndDrag;
//InputManager.Instance.OnFingerMove -= OnItemDrag;
//InputManager.Instance.OnFingerUp -= OnItemEndDrag;
InputManager.Instance.OnFingerMoveUI -= OnItemDrag;
InputManager.Instance.OnFingerUpUI -= OnItemEndDrag;
InputManager.Instance.OnFingerUp -= OnPointerUpFightSkill;
InputManager.Instance.OnFingerUpUI -= OnPointerUpFightSkill;
//InputManager.Instance.OnFingerUp -= OnPointerUpFightSkill;
EventManager.Instance.Unregister(EventManager.EventName.LevelUnitBorn, (Action<GameUnit>)OnListenToFight);
EventManager.Instance.Unregister(EventManager.EventName.LevelBattleBegin, OnListenToFightStateChange);
@ -1643,7 +1645,7 @@ public class UITeamFightController : UIWindow
ScrollView_WaitFight.horizontal = true;
//ScrollView_WaitFight.scrollSensitivity = 1;
if (InputManager.Instance.IsOverUI)
if (TeamManager.Instance.CheckIsOnCancel())//(InputManager.Instance.IsOverUI)
{
OnDragModelEnd(false);
return;
@ -1760,15 +1762,10 @@ public class UITeamFightController : UIWindow
_originalSpeed = LevelManager.Instance.CurrentLevel.GetSpeed();
}
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Slow);
//TeamManager.Instance.SetSelectID(uid);
//EventManager.Instance.Send(EventManager.EventName.LevelUnitSelect, GameUnitManager.instance.infightUnits.Search(uid));
//RefreshFightSelect(TeamManager.Instance.SelectID);
//Character character = LevelManager.Instance.CurrentLevel.CharacterManager.Get(uid);
GameUnit unit = GameUnitManager.instance.infightUnits.Search(uid);
SetSkillPutState(SkillPutState.Dragging);
EventManager.Instance.Send(EventManager.EventName.UI_START_USE_SKILL, unit);
//InputManager.Instance.enabled = false;
if (!TeamManager.IsHideAllUI)
{
TeamManager.IsHideAllUI = true;
@ -1817,14 +1814,15 @@ public class UITeamFightController : UIWindow
return;
}
bool isCancel = RectTransformUtility.RectangleContainsScreenPoint(rect,
InputManager.Instance.GetTouchPosition(),
CameraManager.Instance.UICamera);
// bool isCancel = RectTransformUtility.RectangleContainsScreenPoint(rect,
// InputManager.Instance.GetTouchPosition(),
// CameraManager.Instance.UICamera);
var isCancel = TeamManager.Instance.CheckIsOnCancel();
if (!GameObj_CancelSkill.activeInHierarchy)
{
isCancel = false;
}
// if (!GameObj_CancelSkill.activeInHierarchy)
// {
// isCancel = false;
// }
if (m_curSkillState == SkillPutState.Dragging)

View File

@ -0,0 +1,110 @@
using Framework;
using PhxhSDK;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class UIFightSceneTrigger: IUpdatable
{
public static ButtonEx SceneTrigger;
private UIFightSceneController _window;
private GameObject _goTrigger;
public UIFightSceneTrigger(UIFightSceneController window, string path)
{
_window = window;
SceneTrigger = window.GetComponent<ButtonEx>(path);
_goTrigger = SceneTrigger.gameObject;
Init();
}
public void Init()
{
//SceneTrigger.GetComponent<Image>().raycastTarget = SROptions.Debug_UITriggerRun;
_RegisterEvents();
}
public void Release()
{
SceneTrigger = null;
_window = null;
}
public void Update(float dt)
{
}
#region 触发事件
private enum TriggerState
{
None,
UnitDragging,
SkillDragging,
Release
}
private TriggerState _curState;
private bool _isSkillDragging;
private void _RegisterEvents()
{
SceneTrigger.AddPointerUp(_OnPointerUp);
SceneTrigger.AddPointerDown(_OnPointerDown);
SceneTrigger.AddBeginDrag(_OnBeginDrag);
SceneTrigger.AddOnDrag(_OnDragging);
SceneTrigger.AddEndDrag(_OnEndDrag);
}
#region 按钮事件
private void _OnPointerUp(PointerEventData eventData)
{
switch (_curState)
{
case TriggerState.None:
{
var mousePos = InputManager.Instance.GetTouchPosition();
EventManager.Instance.Send(EventManager.EventName.Level_OnClick, mousePos);
break;
}
default:
break;
}
}
private void _OnPointerDown(PointerEventData eventData)
{
}
private void _OnBeginDrag(PointerEventData eventData)
{
}
private void _OnDragging(PointerEventData eventData)
{
EventManager.Instance.Send(EventManager.EventName.Level_OnDrag, eventData.delta);
}
private void _OnEndDrag(PointerEventData eventData)
{
}
#endregion
#endregion
public void SetTriggerShow(bool show)
{
_goTrigger.SetActive(show);
}
}
public class LevelClick
{
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b88436f5753d4da3bf6a305fd9014cf1
timeCreated: 1725341489

View File

@ -56,6 +56,8 @@ public class UIFightSceneController : UIWindow
[Range(-2.5f, 0)] public float stateOffsetX = -1f;
private UIFightSceneTrigger _sceneTrigger;
// Use this for initialization
public override void OnInit()
{
@ -65,6 +67,7 @@ public class UIFightSceneController : UIWindow
GoNumbers = FindObj("Content/Numbers").gameObject;
imgMask = GetComponent<Image>("ImageMask");
_scrollOccupy = GetComponent<RecycleView>("Content/Occupy/ScrollOccupy");
_sceneTrigger = new UIFightSceneTrigger(this,"Bg");
EventManager.Instance.Register(EventManager.EventName.INFIGHT_GET_DAMAGED,(Action<EventDataGetDamaged>)OnInjured);
EventManager.Instance.Register(EventManager.EventName.LevelBattleBegin, OnBattleBegin);
@ -84,7 +87,8 @@ public class UIFightSceneController : UIWindow
EventManager.Instance.Register(EventManager.EventName.INFIGHT_SKILL_ACTON_UNIT, (Action<GameUnit>)OnAttachToUnit);
EventManager.Instance.Register(EventManager.EventName.UI_START_USE_SKILL, (Action<GameUnit>)OnEnterSkillPut);
EventManager.Instance.Register(EventManager.EventName.OnGetPVPInformation, _OnPVPSettle);
EventManager.Instance.Register(EventManager.EventName.UI_FIGHT_SCENE_SHOW, _SetTriggerShow);
EventManager.Instance.Register(EventManager.EventName.UI_FIGHT_SCENE_HIDE, _SetTriggerHide);
_InitWeatherInfo();
//_scrollOccupy.Init(_RefreshItem);
}
@ -697,10 +701,21 @@ public class UIFightSceneController : UIWindow
EventManager.Instance.Unregister(EventManager.EventName.UI_START_USE_SKILL, (Action<GameUnit>)OnEnterSkillPut);
EventManager.Instance.Unregister(EventManager.EventName.UI_SKILL_CANCEL, OnSkillEnd);
EventManager.Instance.Unregister(EventManager.EventName.OnGetPVPInformation, _OnPVPSettle);
EventManager.Instance.Unregister(EventManager.EventName.UI_FIGHT_SCENE_SHOW, _SetTriggerShow);
EventManager.Instance.Unregister(EventManager.EventName.UI_FIGHT_SCENE_HIDE, _SetTriggerHide);
}
#region Events
private void _SetTriggerShow()
{
_sceneTrigger.SetTriggerShow(true);
}
private void _SetTriggerHide()
{
_sceneTrigger.SetTriggerShow(false);
}
/********** <20><><EFBFBD><EFBFBD> **********/
private void OnInjured(EventDataGetDamaged damageData)
{

View File

@ -7,13 +7,14 @@ using Gameplay.Net;
using Gameplay.Skill;
using PhxhSDK;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class UICommandSkillNode: UINode
{
public Image Image_CMSkillNormal;
public Image Image_SkillProgress;
public UIButtonEx Button_CMSkillPress;
public ButtonEx Button_CMSkillPress;
public Image Image_CMSkillReady;
private UIWindow _bindWindow;
@ -24,8 +25,14 @@ public class UICommandSkillNode: UINode
public override void OnAwake()
{
Button_CMSkillPress.AddOutDragListener(OnOutDrag);
Button_CMSkillPress.AddPointUpListener(OnPointUp);
Button_CMSkillPress.AddBeginDrag(OnOutDrag);
InputManager.Instance.OnFingerUpUI += OnPointUp;
//Button_CMSkillPress.AddPointUpListener(OnPointUp);
}
public void OnDestroy()
{
InputManager.Instance.OnFingerUpUI -= OnPointUp;
}
public override void SetData(object data)
@ -103,7 +110,7 @@ public class UICommandSkillNode: UINode
Button_CMSkillPress.gameObject.SetActive(!state);
}
private void OnOutDrag()
private void OnOutDrag(PointerEventData eventData)
{
try
{
@ -127,7 +134,7 @@ public class UICommandSkillNode: UINode
}
}
private void OnPointUp()
private void OnPointUp(Vector2 pos)
{
CameraController.FingerMoveEnable = true;
var window = (UI_StartBtn_CMSBtnController)_bindWindow;

View File

@ -104,7 +104,7 @@ public class UI_StartBtn_CMSBtnController : UIWindow{
BindButton(Button_StartBtn, OnClickStart);
//BindButton(Button_CMSkillMainPress, OnClickMainPress);
//BindButton(Button_CMSkillMainNormal, OnClickMainPress);
InputManager.Instance.OnFingerUp += OnPointUp;
//InputManager.Instance.OnFingerUp += OnPointUp;
EventManager.Instance.Register(EventManager.EventName.LevelFightStartChange, OnStartChange);
@ -161,7 +161,7 @@ public class UI_StartBtn_CMSBtnController : UIWindow{
{
base.OnRelease();
EventManager.Instance.Unregister(EventManager.EventName.LevelFightStartChange, OnStartChange);
InputManager.Instance.OnFingerUp -= OnPointUp;
//InputManager.Instance.OnFingerUp -= OnPointUp;
}
@ -383,7 +383,6 @@ public class UI_StartBtn_CMSBtnController : UIWindow{
{
/*if (GuideManager.Instance.IsGuiding && GuideManager.Instance.IsControlFloor)
return;*/
try
{
var rect = GoCancelSkill.GetComponent<RectTransform>();