Compare commits

...

10 Commits

Author SHA1 Message Date
ALEXTANG
6a6d33c536 Update AudioAgent.cs 2023-06-25 17:51:17 +08:00
ALEXTANG
57a014a83a [+] Fixed UIWidget
[+] Fixed UIWidget
2023-06-25 15:26:40 +08:00
ALEXTANG
9d1a8e8c9d Create UIEventItem.cs.meta 2023-06-25 15:26:17 +08:00
ALEXTANG
86c26cd21b Create UIEventItem.cs 2023-06-25 15:26:13 +08:00
ALEXTANG
b60b9fff42 Update UIExtension.cs 2023-06-25 15:26:08 +08:00
ALEXTANG
990e17a6cc [+] HybridCLR 补充元数据设置
[+] HybridCLR 补充元数据设置
2023-06-25 15:21:46 +08:00
ALEXTANG
be531bfad0 Fixed the bug for AssetsGroup
Fixed the bug for AssetsGroup
2023-06-23 00:00:58 +08:00
ALEXTANG
6c46f3e5fd [+] Update HybridCLR v3.2.0
[+] Update HybridCLR v3.2.0
2023-06-19 17:17:13 +08:00
ALEXTANG
e4b48e3c58 Update README.md 2023-06-16 14:27:56 +08:00
ALEXTANG
68e5b1d482 Update README.md 2023-06-09 11:40:59 +08:00
11 changed files with 288 additions and 11 deletions

View 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);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f0f07c5dc8f94c20aaf54eb4748cf33b
timeCreated: 1687677786

View File

@@ -7,6 +7,7 @@ using TEngine;
public static class UIExtension
{
#region SetActive
public static void SetActive(this GameObject go, bool value, ref bool cacheValue)
{
if (go != null && value != cacheValue)
@@ -15,6 +16,7 @@ public static class UIExtension
go.SetActive(value);
}
}
#endregion
public static IEnumerator FadeToAlpha(this CanvasGroup canvasGroup, float alpha, float duration,
@@ -110,4 +112,46 @@ public static class UIExtension
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();
}
}
}
}

View File

@@ -92,6 +92,8 @@ MonoBehaviour:
- mscorlib.dll
- System.dll
- System.Core.dll
- UnityEngine.CoreModule.dll
- TEngine.Runtime.dll
LogicMainDllName: GameLogic.dll
AssemblyTextAssetExtension: .bytes
AssemblyTextAssetPath: AssetRaw/DLL

View File

@@ -242,9 +242,9 @@ namespace TEngine
_duration = 0;
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;
}

View File

@@ -325,7 +325,7 @@ namespace TEngine
{
if (typeof(T) == typeof(GameObject))
{
GameObject ret = assetHandleData.Handle.InstantiateSync();
GameObject ret = assetHandleData.Handle.InstantiateSync(parent);
return ret as T;
}
else

View File

@@ -178,6 +178,7 @@ namespace TEngine
{
return false;
}
gameObject = go;
rectTransform = go.GetComponent<RectTransform>();
Log.Assert(rectTransform != null, $"{go.name} ui base element need to be RectTransform");
return true;

View File

@@ -1,6 +1,6 @@
{
"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.pixel-perfect": "5.0.3",
"com.unity.2d.psdimporter": "6.0.7",

View File

@@ -1,11 +1,11 @@
{
"dependencies": {
"com.focus-creative-games.hybridclr_unity": {
"version": "2.4.2",
"com.code-philosophy.hybridclr": {
"version": "https://gitee.com/focus-creative-games/hybridclr_unity.git",
"depth": 0,
"source": "registry",
"source": "git",
"dependencies": {},
"url": "https://package.openupm.cn"
"hash": "8e178c0e372a396e1bf1687e450d85693a95baf4"
},
"com.unity.2d.animation": {
"version": "7.0.9",

View File

@@ -26,7 +26,12 @@ MonoBehaviour:
hotUpdateDllCompileOutputRootDir: HybridCLRData/HotUpdateDlls
externalHotUpdateAssembliyDirs: []
strippedAOTDllOutputRootDir: HybridCLRData/AssembliesPostIl2CppStrip
patchAOTAssemblies: []
patchAOTAssemblies:
- mscorlib.dll
- System.dll
- System.Core.dll
- UnityEngine.CoreModule.dll
- TEngine.Runtime.dll
outputLinkFile: HybridCLRData/Generated/link.xml
outputAOTGenericReferenceFile: HybridCLRData/Generated/AOTGenericReferences.cs
maxGenericReferenceIteration: 10

View File

@@ -145,6 +145,11 @@ Assets
---
## <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/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>