mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Compare commits
10 Commits
TEngine3.0
...
TEngine3.0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6a6d33c536 | ||
![]() |
57a014a83a | ||
![]() |
9d1a8e8c9d | ||
![]() |
86c26cd21b | ||
![]() |
b60b9fff42 | ||
![]() |
990e17a6cc | ||
![]() |
be531bfad0 | ||
![]() |
6c46f3e5fd | ||
![]() |
e4b48e3c58 | ||
![]() |
68e5b1d482 |
217
Assets/GameScripts/HotFix/GameLogic/UI/Common/UIEventItem.cs
Normal file
217
Assets/GameScripts/HotFix/GameLogic/UI/Common/UIEventItem.cs
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
using System;
|
||||||
|
using TEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
class UIEventItem<T> : UIWidget where T : UIEventItem<T>
|
||||||
|
{
|
||||||
|
private object _eventParam1;
|
||||||
|
private object _eventParam2;
|
||||||
|
private object _eventParam3;
|
||||||
|
public object EventParam1 => _eventParam1;
|
||||||
|
public object EventParam2 => _eventParam2;
|
||||||
|
public object EventParam3 => _eventParam3;
|
||||||
|
private Action<T> _clickAction;
|
||||||
|
private Action<T, bool> _pressAction;
|
||||||
|
private Action<T, PointerEventData> _beginDragAction;
|
||||||
|
private Action<T, PointerEventData> _dragAction;
|
||||||
|
private Action<T, PointerEventData> _endDragAction;
|
||||||
|
|
||||||
|
public void BindClickEvent(Action<T> clickAction, object eParam1 = null, object eParam2 = null, object eParam3 = null,Selectable.Transition transition = Selectable.Transition.ColorTint)
|
||||||
|
{
|
||||||
|
if (_clickAction != null)
|
||||||
|
{
|
||||||
|
_clickAction = clickAction;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_clickAction = clickAction;
|
||||||
|
var button = DUnityUtil.AddMonoBehaviour<Button>(gameObject);
|
||||||
|
button.transition = transition;
|
||||||
|
button.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
if (_clickAction != null)
|
||||||
|
{
|
||||||
|
_clickAction(this as T);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
SetEventParam(eParam1, eParam2, eParam3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BindClickEventEx(Action<T> clickAction, object eParam1 = null, object eParam2 = null, object eParam3 = null)
|
||||||
|
{
|
||||||
|
if (_clickAction != null)
|
||||||
|
{
|
||||||
|
_clickAction = clickAction;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_clickAction = clickAction;
|
||||||
|
var button = DUnityUtil.AddMonoBehaviour<Button>(gameObject);
|
||||||
|
button.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
if (_clickAction != null)
|
||||||
|
{
|
||||||
|
_clickAction(this as T);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
SetEventParam(eParam1, eParam2, eParam3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BindBeginDragEvent(Action<T, PointerEventData> dragAction, object eParam1 = null, object eParam2 = null, object eParam3 = null)
|
||||||
|
{
|
||||||
|
if (_beginDragAction != null)
|
||||||
|
{
|
||||||
|
_beginDragAction = dragAction;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_beginDragAction = dragAction;
|
||||||
|
var trigger = DUnityUtil.AddMonoBehaviour<EventTrigger>(gameObject);
|
||||||
|
EventTrigger.Entry entry = new EventTrigger.Entry
|
||||||
|
{
|
||||||
|
eventID = EventTriggerType.BeginDrag,
|
||||||
|
callback = new EventTrigger.TriggerEvent()
|
||||||
|
};
|
||||||
|
entry.callback.AddListener(data =>
|
||||||
|
{
|
||||||
|
var pointerEventData = (PointerEventData)data;
|
||||||
|
if (_beginDragAction != null)
|
||||||
|
{
|
||||||
|
_beginDragAction(this as T, pointerEventData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
trigger.triggers.Add(entry);
|
||||||
|
}
|
||||||
|
SetEventParam(eParam1, eParam2, eParam3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BindDragEvent(Action<T, PointerEventData> dragAction, object eParam1 = null, object eParam2 = null, object eParam3 = null)
|
||||||
|
{
|
||||||
|
if (_dragAction != null)
|
||||||
|
{
|
||||||
|
_dragAction = dragAction;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_dragAction = dragAction;
|
||||||
|
var trigger = DUnityUtil.AddMonoBehaviour<EventTrigger>(gameObject);
|
||||||
|
EventTrigger.Entry entry = new EventTrigger.Entry();
|
||||||
|
entry.eventID = EventTriggerType.Drag;
|
||||||
|
entry.callback = new EventTrigger.TriggerEvent();
|
||||||
|
entry.callback.AddListener(data =>
|
||||||
|
{
|
||||||
|
var pointerEventData = (PointerEventData)data;
|
||||||
|
if (_dragAction != null)
|
||||||
|
{
|
||||||
|
_dragAction(this as T, pointerEventData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
trigger.triggers.Add(entry);
|
||||||
|
}
|
||||||
|
SetEventParam(eParam1, eParam2, eParam3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BindEndDragEvent(Action<T, PointerEventData> dragendAction, object eParam1 = null, object eParam2 = null, object eParam3 = null)
|
||||||
|
{
|
||||||
|
if (_endDragAction != null)
|
||||||
|
{
|
||||||
|
_endDragAction = dragendAction;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_endDragAction = dragendAction;
|
||||||
|
var trigger = DUnityUtil.AddMonoBehaviour<EventTrigger>(gameObject);
|
||||||
|
EventTrigger.Entry entry = new EventTrigger.Entry();
|
||||||
|
entry.eventID = EventTriggerType.EndDrag;
|
||||||
|
entry.callback = new EventTrigger.TriggerEvent();
|
||||||
|
entry.callback.AddListener((data) =>
|
||||||
|
{
|
||||||
|
if (_endDragAction != null)
|
||||||
|
{
|
||||||
|
_endDragAction(this as T, (PointerEventData)data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
trigger.triggers.Add(entry);
|
||||||
|
}
|
||||||
|
SetEventParam(eParam1, eParam2, eParam3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BindPressEvent(Action<T, bool> pressAction, object eParam1 = null, object eParam2 = null, object eParam3 = null)
|
||||||
|
{
|
||||||
|
if (_pressAction != null)
|
||||||
|
{
|
||||||
|
_pressAction = pressAction;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_pressAction = pressAction;
|
||||||
|
var trigger = DUnityUtil.AddMonoBehaviour<EventTrigger>(gameObject);
|
||||||
|
EventTrigger.Entry entry = new EventTrigger.Entry();
|
||||||
|
entry.eventID = EventTriggerType.PointerDown;
|
||||||
|
entry.callback = new EventTrigger.TriggerEvent();
|
||||||
|
entry.callback.AddListener(data =>
|
||||||
|
{
|
||||||
|
if (_pressAction != null)
|
||||||
|
{
|
||||||
|
_pressAction(this as T, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
trigger.triggers.Add(entry);
|
||||||
|
entry = new EventTrigger.Entry();
|
||||||
|
entry.eventID = EventTriggerType.PointerUp;
|
||||||
|
entry.callback = new EventTrigger.TriggerEvent();
|
||||||
|
entry.callback.AddListener((data) =>
|
||||||
|
{
|
||||||
|
if (_pressAction != null)
|
||||||
|
{
|
||||||
|
_pressAction(this as T, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
trigger.triggers.Add(entry);
|
||||||
|
}
|
||||||
|
SetEventParam(eParam1, eParam2, eParam3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BindPressEventEx(Action<T, bool> pressAction, object eParam1 = null, object eParam2 = null, object eParam3 = null,float durationThreshold = 1)
|
||||||
|
{
|
||||||
|
if (_pressAction != null)
|
||||||
|
{
|
||||||
|
_pressAction = pressAction;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_pressAction = pressAction;
|
||||||
|
var button = DUnityUtil.AddMonoBehaviour<UIButtonSuper>(gameObject);
|
||||||
|
button.m_LongPressDurationTime = durationThreshold;
|
||||||
|
button.onPress.AddListener(() =>
|
||||||
|
{
|
||||||
|
if (_pressAction != null)
|
||||||
|
{
|
||||||
|
_pressAction(this as T, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
SetEventParam(eParam1, eParam2, eParam3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetEventParam(object eParam1, object eParam2 = null, object eParam3 = null)
|
||||||
|
{
|
||||||
|
_eventParam1 = eParam1;
|
||||||
|
_eventParam2 = eParam2;
|
||||||
|
_eventParam3 = eParam3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnTriggerBtnEvent()
|
||||||
|
{
|
||||||
|
if (_clickAction != null)
|
||||||
|
{
|
||||||
|
_clickAction(this as T);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f0f07c5dc8f94c20aaf54eb4748cf33b
|
||||||
|
timeCreated: 1687677786
|
@@ -7,6 +7,7 @@ using TEngine;
|
|||||||
public static class UIExtension
|
public static class UIExtension
|
||||||
{
|
{
|
||||||
#region SetActive
|
#region SetActive
|
||||||
|
|
||||||
public static void SetActive(this GameObject go, bool value, ref bool cacheValue)
|
public static void SetActive(this GameObject go, bool value, ref bool cacheValue)
|
||||||
{
|
{
|
||||||
if (go != null && value != cacheValue)
|
if (go != null && value != cacheValue)
|
||||||
@@ -15,6 +16,7 @@ public static class UIExtension
|
|||||||
go.SetActive(value);
|
go.SetActive(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static IEnumerator FadeToAlpha(this CanvasGroup canvasGroup, float alpha, float duration,
|
public static IEnumerator FadeToAlpha(this CanvasGroup canvasGroup, float alpha, float duration,
|
||||||
@@ -110,4 +112,46 @@ public static class UIExtension
|
|||||||
|
|
||||||
return hadMouseDown;
|
return hadMouseDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetSprite(this Image image, string spriteName, UIBase uiBase, bool isSetNativeSize = false)
|
||||||
|
{
|
||||||
|
if (image == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(spriteName))
|
||||||
|
{
|
||||||
|
image.sprite = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
image.sprite = uiBase.LoadAsset<Sprite>(spriteName);
|
||||||
|
if (isSetNativeSize)
|
||||||
|
{
|
||||||
|
image.SetNativeSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetSprite(this UIBase uiBase, string spriteName, Image image, bool isSetNativeSize = false)
|
||||||
|
{
|
||||||
|
if (image == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(spriteName))
|
||||||
|
{
|
||||||
|
image.sprite = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
image.sprite = uiBase.LoadAsset<Sprite>(spriteName);
|
||||||
|
if (isSetNativeSize)
|
||||||
|
{
|
||||||
|
image.SetNativeSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -92,6 +92,8 @@ MonoBehaviour:
|
|||||||
- mscorlib.dll
|
- mscorlib.dll
|
||||||
- System.dll
|
- System.dll
|
||||||
- System.Core.dll
|
- System.Core.dll
|
||||||
|
- UnityEngine.CoreModule.dll
|
||||||
|
- TEngine.Runtime.dll
|
||||||
LogicMainDllName: GameLogic.dll
|
LogicMainDllName: GameLogic.dll
|
||||||
AssemblyTextAssetExtension: .bytes
|
AssemblyTextAssetExtension: .bytes
|
||||||
AssemblyTextAssetPath: AssetRaw/DLL
|
AssemblyTextAssetPath: AssetRaw/DLL
|
||||||
|
@@ -242,9 +242,9 @@ namespace TEngine
|
|||||||
_duration = 0;
|
_duration = 0;
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
if (GameModule.Audio.AudioClipPool.ContainsKey(path))
|
if (GameModule.Audio.AudioClipPool.TryGetValue(path, out var operationHandle))
|
||||||
{
|
{
|
||||||
OnAssetLoadComplete(GameModule.Audio.AudioClipPool[path]);
|
OnAssetLoadComplete(operationHandle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -325,7 +325,7 @@ namespace TEngine
|
|||||||
{
|
{
|
||||||
if (typeof(T) == typeof(GameObject))
|
if (typeof(T) == typeof(GameObject))
|
||||||
{
|
{
|
||||||
GameObject ret = assetHandleData.Handle.InstantiateSync();
|
GameObject ret = assetHandleData.Handle.InstantiateSync(parent);
|
||||||
return ret as T;
|
return ret as T;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -178,6 +178,7 @@ namespace TEngine
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
gameObject = go;
|
||||||
rectTransform = go.GetComponent<RectTransform>();
|
rectTransform = go.GetComponent<RectTransform>();
|
||||||
Log.Assert(rectTransform != null, $"{go.name} ui base element need to be RectTransform");
|
Log.Assert(rectTransform != null, $"{go.name} ui base element need to be RectTransform");
|
||||||
return true;
|
return true;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.focus-creative-games.hybridclr_unity": "2.4.2",
|
"com.code-philosophy.hybridclr": "https://gitee.com/focus-creative-games/hybridclr_unity.git",
|
||||||
"com.unity.2d.animation": "7.0.9",
|
"com.unity.2d.animation": "7.0.9",
|
||||||
"com.unity.2d.pixel-perfect": "5.0.3",
|
"com.unity.2d.pixel-perfect": "5.0.3",
|
||||||
"com.unity.2d.psdimporter": "6.0.7",
|
"com.unity.2d.psdimporter": "6.0.7",
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.focus-creative-games.hybridclr_unity": {
|
"com.code-philosophy.hybridclr": {
|
||||||
"version": "2.4.2",
|
"version": "https://gitee.com/focus-creative-games/hybridclr_unity.git",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "registry",
|
"source": "git",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"url": "https://package.openupm.cn"
|
"hash": "8e178c0e372a396e1bf1687e450d85693a95baf4"
|
||||||
},
|
},
|
||||||
"com.unity.2d.animation": {
|
"com.unity.2d.animation": {
|
||||||
"version": "7.0.9",
|
"version": "7.0.9",
|
||||||
|
@@ -26,7 +26,12 @@ MonoBehaviour:
|
|||||||
hotUpdateDllCompileOutputRootDir: HybridCLRData/HotUpdateDlls
|
hotUpdateDllCompileOutputRootDir: HybridCLRData/HotUpdateDlls
|
||||||
externalHotUpdateAssembliyDirs: []
|
externalHotUpdateAssembliyDirs: []
|
||||||
strippedAOTDllOutputRootDir: HybridCLRData/AssembliesPostIl2CppStrip
|
strippedAOTDllOutputRootDir: HybridCLRData/AssembliesPostIl2CppStrip
|
||||||
patchAOTAssemblies: []
|
patchAOTAssemblies:
|
||||||
|
- mscorlib.dll
|
||||||
|
- System.dll
|
||||||
|
- System.Core.dll
|
||||||
|
- UnityEngine.CoreModule.dll
|
||||||
|
- TEngine.Runtime.dll
|
||||||
outputLinkFile: HybridCLRData/Generated/link.xml
|
outputLinkFile: HybridCLRData/Generated/link.xml
|
||||||
outputAOTGenericReferenceFile: HybridCLRData/Generated/AOTGenericReferences.cs
|
outputAOTGenericReferenceFile: HybridCLRData/Generated/AOTGenericReferences.cs
|
||||||
maxGenericReferenceIteration: 10
|
maxGenericReferenceIteration: 10
|
||||||
|
@@ -145,6 +145,11 @@ Assets
|
|||||||
|
|
||||||
---
|
---
|
||||||
## <strong>优质开源项目推荐
|
## <strong>优质开源项目推荐
|
||||||
|
|
||||||
|
### <a href="https://github.com/tuyoogame/YooAsset"><strong>YooAsset</strong></a> - YooAsset是一套商业级经历百万DAU游戏验证的资源管理系统。
|
||||||
#### <a href="https://github.com/JasonXuDeveloper/JEngine"><strong>JEngine</strong></a> - 使Unity开发的游戏支持热更新的解决方案。
|
#### <a href="https://github.com/JasonXuDeveloper/JEngine"><strong>JEngine</strong></a> - 使Unity开发的游戏支持热更新的解决方案。
|
||||||
|
|
||||||
#### <a href="https://github.com/focus-creative-games/hybridclr"><strong>HybridCLR</strong></a> - 特性完整、零成本、高性能、低内存的近乎完美的Unity全平台原生c#热更方案
|
#### <a href="https://github.com/focus-creative-games/hybridclr"><strong>HybridCLR</strong></a> - 特性完整、零成本、高性能、低内存的近乎完美的Unity全平台原生c#热更方案
|
||||||
|
|
||||||
|
## <strong>交流群
|
||||||
|
### <a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MzOcQIzGVLQ5AC5LHaqqA3h_F6lZ_DX4&authKey=LctqAWGHkJ7voQvuj1oaSe5tsGrc1XmQG3U4QniieGUlxY3lC7FtDIpEvPOX0vT8&noverify=0&group_code=862987645">群 号:862987645 </strong></a>
|
||||||
|
Reference in New Issue
Block a user