初始化
This commit is contained in:
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 355f6b3f68d84fb38992a3edf87520ab
|
||||
timeCreated: 1681370085
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Active.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Active.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fd1a1e2dd384350879f5c38fdb2bf36
|
||||
timeCreated: 1685433427
|
||||
@@ -0,0 +1,116 @@
|
||||
using System.Collections;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using YIUIFramework;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[LabelText("GameObject的显隐")]
|
||||
[AddComponentMenu("YIUIBind/Data/显隐 【Active】 UIDataBindActive")]
|
||||
public sealed class UIDataBindActive : UIDataBindBool
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("过度类型")]
|
||||
private UITransitionModeEnum m_TransitionMode = UITransitionModeEnum.Instant;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("过度时间")]
|
||||
[HideIf("m_TransitionMode", UITransitionModeEnum.Instant)]
|
||||
private float m_TransitionTime = 0.5f;
|
||||
|
||||
private CanvasGroup m_CanvasGroup;
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (gameObject == null)
|
||||
return;
|
||||
|
||||
var result = GetResult();
|
||||
|
||||
if (m_TransitionMode == UITransitionModeEnum.Instant)
|
||||
{
|
||||
gameObject.SetActive(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_CanvasGroup == null)
|
||||
{
|
||||
m_CanvasGroup = gameObject.GetOrAddComponent<CanvasGroup>();
|
||||
}
|
||||
|
||||
if (m_CanvasGroup != null)
|
||||
{
|
||||
StopAllCoroutines();
|
||||
|
||||
switch (m_TransitionMode)
|
||||
{
|
||||
case UITransitionModeEnum.Fade:
|
||||
if (result)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
StartCoroutine(TransitionFade(m_CanvasGroup, 1.0f, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(TransitionFade(m_CanvasGroup, 0.0f, false));
|
||||
}
|
||||
|
||||
break;
|
||||
case UITransitionModeEnum.FadeIn:
|
||||
if (result)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
m_CanvasGroup.alpha = 0;
|
||||
StartCoroutine(TransitionFade(m_CanvasGroup, 1.0f, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
break;
|
||||
case UITransitionModeEnum.FadeOut:
|
||||
if (result)
|
||||
{
|
||||
m_CanvasGroup.alpha = 1f;
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CanvasGroup.alpha = 1f;
|
||||
StartCoroutine(TransitionFade(m_CanvasGroup, 0.0f, false));
|
||||
}
|
||||
|
||||
break;
|
||||
case UITransitionModeEnum.Instant:
|
||||
default:
|
||||
gameObject.SetActive(result);
|
||||
Debug.LogError($"不支持的功能 {m_TransitionMode}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.SetActive(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator TransitionFade(CanvasGroup group, float alphaTarget, bool activeTarget)
|
||||
{
|
||||
var leftTime = m_TransitionTime;
|
||||
var alphaStart = group.alpha;
|
||||
while (leftTime > 0.0f)
|
||||
{
|
||||
yield return null;
|
||||
leftTime -= Time.deltaTime;
|
||||
var alpha = Mathf.Lerp(alphaStart,
|
||||
alphaTarget,
|
||||
1.0f - (leftTime / m_TransitionTime));
|
||||
group.alpha = alpha;
|
||||
}
|
||||
|
||||
group.gameObject.SetActive(activeTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da50a1326ce847e5ac0ccab8fedf96bd
|
||||
timeCreated: 1679150770
|
||||
@@ -0,0 +1,62 @@
|
||||
using System.Collections;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[LabelText("任意Component的显隐")]
|
||||
[AddComponentMenu("YIUIBind/Data/显隐 【ActiveComponent】 UIDataBindActiveComponent l")]
|
||||
public sealed class UIDataBindActiveComponent : UIDataBindBool
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("控制的目标")]
|
||||
[Required("必须有此组件")]
|
||||
private Behaviour m_Target;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("过度类型")]
|
||||
private UITransitionModeEnum m_TransitionMode = UITransitionModeEnum.Instant;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("过度时间")]
|
||||
[ShowIf("m_TransitionMode", UITransitionModeEnum.Fade)]
|
||||
private float m_TransitionTime = 0.1f;
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Target == null)
|
||||
return;
|
||||
|
||||
var result = GetResult();
|
||||
|
||||
if (m_TransitionMode == UITransitionModeEnum.Instant)
|
||||
{
|
||||
m_Target.enabled = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_WaitForSeconds ??= new WaitForSeconds(m_TransitionTime);
|
||||
m_Coroutine = StartCoroutine(WaitTime(result));
|
||||
}
|
||||
}
|
||||
|
||||
private WaitForSeconds m_WaitForSeconds;
|
||||
private Coroutine m_Coroutine;
|
||||
|
||||
private IEnumerator WaitTime(bool result)
|
||||
{
|
||||
yield return m_WaitForSeconds;
|
||||
m_Target.enabled = result;
|
||||
m_Coroutine = null;
|
||||
}
|
||||
|
||||
private new void OnDestroy()
|
||||
{
|
||||
if (m_Coroutine != null)
|
||||
{
|
||||
StopCoroutine(m_Coroutine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c24ac02183c24da6852a83939c03b26e
|
||||
timeCreated: 1681112228
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[LabelText("任意集合的Component的显隐")]
|
||||
[AddComponentMenu("YIUIBind/Data/显隐 【ActiveComponents】 UIDataBindActiveComponents s")]
|
||||
public sealed class UIDataBindActiveComponents : UIDataBindBool
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("控制的目标")]
|
||||
[Required("必须有此组件")]
|
||||
private List<Behaviour> m_Targets = new List<Behaviour>();
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("过度类型")]
|
||||
private UITransitionModeEnum m_TransitionMode = UITransitionModeEnum.Instant;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("过度时间")]
|
||||
[ShowIf("m_TransitionMode", UITransitionModeEnum.Fade)]
|
||||
private float m_TransitionTime = 0.1f;
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Targets == null)
|
||||
return;
|
||||
|
||||
var result = GetResult();
|
||||
|
||||
if (m_TransitionMode == UITransitionModeEnum.Instant)
|
||||
{
|
||||
SetEnabled(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_WaitForSeconds ??= new WaitForSeconds(m_TransitionTime);
|
||||
m_Coroutine = StartCoroutine(WaitTime(result));
|
||||
}
|
||||
}
|
||||
|
||||
private WaitForSeconds m_WaitForSeconds;
|
||||
private Coroutine m_Coroutine;
|
||||
|
||||
private IEnumerator WaitTime(bool result)
|
||||
{
|
||||
yield return m_WaitForSeconds;
|
||||
SetEnabled(result);
|
||||
m_Coroutine = null;
|
||||
}
|
||||
|
||||
private void SetEnabled(bool set)
|
||||
{
|
||||
foreach (var value in m_Targets)
|
||||
{
|
||||
value.enabled = set;
|
||||
}
|
||||
}
|
||||
|
||||
private new void OnDestroy()
|
||||
{
|
||||
if (m_Coroutine != null)
|
||||
{
|
||||
StopCoroutine(m_Coroutine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acba7b0d00a34b7abae40d2bd8df8900
|
||||
timeCreated: 1681371022
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[LabelText("任意集合的GameObject的显隐")]
|
||||
[AddComponentMenu("YIUIBind/Data/显隐 【ActiveGameObjects】 UIDataBindActiveGameObjects y")]
|
||||
public sealed class UIDataBindActiveGameObjects : UIDataBindBool
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("控制的目标")]
|
||||
[Required("必须有此组件")]
|
||||
private GameObject[] m_Targets;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("过度类型")]
|
||||
private UITransitionModeEnum m_TransitionMode = UITransitionModeEnum.Instant;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("过度时间")]
|
||||
[ShowIf("m_TransitionMode", UITransitionModeEnum.Fade)]
|
||||
private float m_TransitionTime = 0.1f;
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Targets == null)
|
||||
return;
|
||||
|
||||
var result = GetResult();
|
||||
|
||||
if (m_TransitionMode == UITransitionModeEnum.Instant)
|
||||
{
|
||||
SetActive(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_WaitForSeconds ??= new WaitForSeconds(m_TransitionTime);
|
||||
m_Coroutine = StartCoroutine(WaitTime(result));
|
||||
}
|
||||
}
|
||||
|
||||
private WaitForSeconds m_WaitForSeconds;
|
||||
private Coroutine m_Coroutine;
|
||||
|
||||
private IEnumerator WaitTime(bool result)
|
||||
{
|
||||
yield return m_WaitForSeconds;
|
||||
SetActive(result);
|
||||
m_Coroutine = null;
|
||||
}
|
||||
|
||||
private void SetActive(bool set)
|
||||
{
|
||||
foreach (var value in m_Targets)
|
||||
{
|
||||
value.SetActive(set);
|
||||
}
|
||||
}
|
||||
|
||||
private new void OnDestroy()
|
||||
{
|
||||
if (m_Coroutine != null)
|
||||
{
|
||||
StopCoroutine(m_Coroutine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fdef117492a403b959a265f47f80347
|
||||
timeCreated: 1681371300
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 870a31dd2c8b4fe0b5204567bd589950
|
||||
timeCreated: 1685433469
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[RequireComponent(typeof(Animation))]
|
||||
[DetailedInfoBox("注意动画组件的 自动播放不要勾选",
|
||||
@"会根据配置播放当前配置上默认的Animation 如果要实现播放不同的动画还需要搭配另外一个传入名称的参数
|
||||
使用方法:
|
||||
1 挂上 Animation 组件
|
||||
2 Ctrl + 6 动态创建一个动画片段
|
||||
3 吧对应的动画片段拖到组件中
|
||||
4 默认会使用第一个动画")]
|
||||
[LabelText("动画")]
|
||||
[AddComponentMenu("YIUIBind/Data/动画 【Animation】 UIDataBindAnimation")]
|
||||
public sealed class UIDataBindAnimation : UIDataBindBool
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("动画")]
|
||||
private Animation m_Animation;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Animation ??= GetComponent<Animation>();
|
||||
if (m_Animation != null)
|
||||
{
|
||||
m_Animation.playAutomatically = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Animation == null) return;
|
||||
|
||||
if (m_Animation.clip == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var result = GetResult();
|
||||
if (result)
|
||||
{
|
||||
m_Animation.Play(m_Animation.clip.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Animation.Stop(m_Animation.clip.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 898a10eeeed249a1b546254759d16178
|
||||
timeCreated: 1681459915
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[RequireComponent(typeof(Animation))]
|
||||
[DetailedInfoBox("注意动画组件的 自动播放不要勾选",
|
||||
@"根据名称播放动画 不存在则会提示
|
||||
使用方法:
|
||||
1 挂上 Animation 组件
|
||||
2 Ctrl + 6 动态创建一个动画片段
|
||||
3 吧对应的动画片段拖到组件中
|
||||
4 修改了组件后记得保存 触发一次刷新")]
|
||||
[LabelText("动画")]
|
||||
[AddComponentMenu("YIUIBind/Data/动画 【AnimationByName】 UIDataBindAnimationByName")]
|
||||
public sealed class UIDataBindAnimationByName : UIDataBindSelectBase
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("动画")]
|
||||
private Animation m_Animation;
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[LabelText("当前所有可用动画")]
|
||||
private List<string> m_AllClipName = new List<string>();
|
||||
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.String;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Animation ??= GetComponent<Animation>();
|
||||
if (m_Animation != null)
|
||||
{
|
||||
m_Animation.playAutomatically = false;
|
||||
#if UNITY_EDITOR
|
||||
m_AllClipName.Clear();
|
||||
|
||||
var clips = AnimationUtility.GetAnimationClips(m_Animation.gameObject);
|
||||
|
||||
foreach (var clip in clips)
|
||||
{
|
||||
m_AllClipName.Add(clip.name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
m_AllClipName.Clear();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Animation == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<string>();
|
||||
if (string.IsNullOrEmpty(dataValue)) return;
|
||||
|
||||
if (!m_AllClipName.Contains(dataValue))
|
||||
{
|
||||
Logger.LogErrorContext(this, $"{name} 播放失败 请检查动画名称是否存在 {dataValue}");
|
||||
return;
|
||||
}
|
||||
|
||||
m_Animation.Play(dataValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cc6728f0cd84e6bbc4edad5a6c04822
|
||||
timeCreated: 1681466244
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Change.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Change.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33ef4eb74f2646409335af9334525ce1
|
||||
timeCreated: 1685431716
|
||||
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using YIUIFramework;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 改变绑定数据 配合 event使用
|
||||
/// 由event触发 然后吧对应的值修改
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[DetailedInfoBox("改变数据",
|
||||
@"根据提前关联的数据 触发时会将关联的数据修改成提前预设的数据
|
||||
内置一个改变响应事件 可以注册这个事件做回调处理
|
||||
Event 那边已经做好一个自动关联 可以直接关联到事件回调
|
||||
因为有接口 IPointerClickHandler 所以任何可以被射线检测到的都可以点击
|
||||
不一定需要Selectable组件 他不是必须的")]
|
||||
[LabelText("改变数据")]
|
||||
[AddComponentMenu("YIUIBind/Data/★改变数据 【Change】 UIDataBindSelectBase")]
|
||||
public class UIDataBindChange : UIDataBindSelectBase, IPointerClickHandler
|
||||
{
|
||||
[OdinSerialize]
|
||||
[ShowInInspector]
|
||||
[LabelText("所有需要改变的数据")]
|
||||
[ListDrawerSettings(IsReadOnly = true)]
|
||||
#if UNITY_EDITOR
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
#endif
|
||||
private List<UIDataChangeRef> m_Datas = new List<UIDataChangeRef>();
|
||||
|
||||
[OdinSerialize]
|
||||
[ShowInInspector]
|
||||
[LabelText("响应点击")]
|
||||
#if UNITY_EDITOR
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
#endif
|
||||
private bool m_InvokeClick = true;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("拖拽时不响应点击")]
|
||||
[ShowIf("m_InvokeClick")]
|
||||
#if UNITY_EDITOR
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
#endif
|
||||
private bool m_SkipWhenDrag;
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[LabelText("可选组件")]
|
||||
[ShowIf("m_InvokeClick")]
|
||||
private Selectable m_Selectable;
|
||||
|
||||
private event Action OnChangeDataValueAction;
|
||||
|
||||
public void AddChangeAction(Action changeAction)
|
||||
{
|
||||
OnChangeDataValueAction -= changeAction;
|
||||
OnChangeDataValueAction += changeAction;
|
||||
}
|
||||
|
||||
public void RemoveChangeAction(Action changeAction)
|
||||
{
|
||||
OnChangeDataValueAction -= changeAction;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (!m_InvokeClick) return;
|
||||
|
||||
if (m_Selectable != null && !m_Selectable.interactable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_SkipWhenDrag && eventData.dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ChangeDataValue();
|
||||
}
|
||||
|
||||
protected override int Mask()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
[GUIColor(0, 1, 1)]
|
||||
[Button("响应点击", 30)]
|
||||
[ShowIf("m_InvokeClick")]
|
||||
[PropertyOrder(-100)]
|
||||
public void ChangeDataValue()
|
||||
{
|
||||
if (m_Datas == null || m_Datas.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var changeData in m_Datas)
|
||||
{
|
||||
changeData.Data.SetValueFrom(changeData.ChangeData);
|
||||
changeData.Refresh(changeData.Data);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OnChangeDataValueAction?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
|
||||
//循环比较
|
||||
//没有的就删除
|
||||
//缺少的就添加
|
||||
//且同步修改后的名字
|
||||
m_Selectable ??= GetComponent<Selectable>();
|
||||
|
||||
foreach (var target in DataSelectDic.Values)
|
||||
{
|
||||
var exist = false;
|
||||
|
||||
//我的
|
||||
foreach (var self in m_Datas)
|
||||
{
|
||||
if (target.Data.DataGuid == self.Data.DataGuid)
|
||||
{
|
||||
//存在则刷新
|
||||
self.Refresh(target.Data);
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (exist) continue;
|
||||
|
||||
//说明不存在
|
||||
m_Datas.Add(new UIDataChangeRef(target.Data));
|
||||
}
|
||||
|
||||
//需要移除 所以从后往前
|
||||
for (var i = m_Datas.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var self = m_Datas[i];
|
||||
var exist = false;
|
||||
foreach (var target in DataSelectDic.Values)
|
||||
{
|
||||
if (target.Data.DataGuid == self.Data.DataGuid)
|
||||
{
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (exist) continue;
|
||||
|
||||
//说明不一样
|
||||
m_Datas.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private UIEventBindChangeDataValue m_UIEventBindChangeDataValue;
|
||||
|
||||
[ShowIf("ShowAddEventBtn")]
|
||||
[Button("添加事件", 30)]
|
||||
#if UNITY_EDITOR
|
||||
[EnableIf("@UIOperationHelper.CommonShowIf()")]
|
||||
#endif
|
||||
private void AddEventChange()
|
||||
{
|
||||
m_UIEventBindChangeDataValue = gameObject.GetOrAddComponent<UIEventBindChangeDataValue>();
|
||||
}
|
||||
|
||||
private bool ShowAddEventBtn()
|
||||
{
|
||||
if (!m_InvokeClick) return false;
|
||||
return m_UIEventBindChangeDataValue == null;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffe7370335d64bdc8c507fb12e6f6566
|
||||
timeCreated: 1679640796
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 改变绑定数据 配合 其他数据使用
|
||||
/// 由其他数据改变触发 然后吧对应的值修改
|
||||
/// 可挂载在任意对象上 需要一个载体
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[DetailedInfoBox("改变数据条件",
|
||||
@"当条件触发时 改变对应的数据 依赖UIDataBindChange
|
||||
原理就是满足bool 条件后 触发改变多对多")]
|
||||
[LabelText("改变数据条件")]
|
||||
[RequireComponent(typeof(UIDataBindChange))]
|
||||
[AddComponentMenu("YIUIBind/Data/★改变数据条件 【Change Condition】 UIDataBindChangeCondition")]
|
||||
public class UIDataBindChangeCondition : UIDataBindBool
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
private UIDataBindChange m_UIDataBindChange;
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
var result = GetResult();
|
||||
if (!result) return;
|
||||
|
||||
m_UIDataBindChange.ChangeDataValue();
|
||||
}
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_UIDataBindChange ??= GetComponent<UIDataBindChange>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c5d59b2113b4b9ba5211c7a78ae3eed
|
||||
timeCreated: 1685431611
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[HideReferenceObjectPicker]
|
||||
internal class UIDataChangeRef
|
||||
{
|
||||
//当前的变量
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private UIData m_Data;
|
||||
|
||||
public UIData Data => m_Data;
|
||||
|
||||
[ShowInInspector]
|
||||
[LabelText("名称")]
|
||||
[ReadOnly]
|
||||
private string m_DataName;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[ShowInInspector]
|
||||
[LabelText("值")]
|
||||
[ReadOnly]
|
||||
private string m_DataValue;
|
||||
#endif
|
||||
|
||||
[ShowInInspector]
|
||||
[OdinSerialize]
|
||||
private UIDataValue m_ChangeData;
|
||||
|
||||
public UIDataValue ChangeData => m_ChangeData;
|
||||
|
||||
private UIDataChangeRef()
|
||||
{
|
||||
}
|
||||
|
||||
public UIDataChangeRef(UIData data)
|
||||
{
|
||||
Refresh(data);
|
||||
}
|
||||
|
||||
//刷新数据
|
||||
public void Refresh(UIData data)
|
||||
{
|
||||
m_Data = data;
|
||||
m_DataName = m_Data.Name;
|
||||
|
||||
if (m_ChangeData == null || m_ChangeData.UIBindDataType != data.DataValue.UIBindDataType)
|
||||
{
|
||||
m_ChangeData = UIDataHelper.GetNewDataValue(data.DataValue);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
m_DataValue = m_Data.GetValueToString();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 817e132f63534959ab41ec9c4b27840f
|
||||
timeCreated: 1685431735
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Image.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Image.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2c88ea5200249b5b95733f4983e7b5e
|
||||
timeCreated: 1688112643
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("改变颜色")]
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
[AddComponentMenu("YIUIBind/Data/颜色 【Color】 UIDataBindColor")]
|
||||
public class UIDataBindColor : UIDataBindSelectBase
|
||||
{
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Color;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("图")]
|
||||
private Graphic m_Graphic;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Graphic ??= GetComponent<Graphic>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
var dataValue = GetFirstValue<Color>();
|
||||
|
||||
if (m_Graphic != null)
|
||||
{
|
||||
m_Graphic.color = dataValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fb4f484aa8b4ecc992f79bb7963dbcf
|
||||
timeCreated: 1681373090
|
||||
@@ -0,0 +1,39 @@
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using YIUIFramework;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[LabelText("置灰")]
|
||||
[RequireComponent(typeof(UIGrayscale))]
|
||||
[AddComponentMenu("YIUIBind/Data/置灰 【Gray】 UIDataBindGray")]
|
||||
public sealed class UIDataBindGray : UIDataBindBool
|
||||
{
|
||||
[SerializeField]
|
||||
[Range(0, 255)]
|
||||
private int m_EnabledGray = 0;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0, 255)]
|
||||
private int m_DisabledGray = 255;
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("UI灰度")]
|
||||
private UIGrayscale m_Grayscale;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Grayscale ??= GetComponent<UIGrayscale>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Grayscale == null) return;
|
||||
|
||||
m_Grayscale.GrayScale = GetResult() ? m_EnabledGray : m_DisabledGray;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7dd2b76174e640cf8dab76b6103998e5
|
||||
timeCreated: 1681377252
|
||||
@@ -0,0 +1,151 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using YIUIFramework;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[RequireComponent(typeof(Image))]
|
||||
[LabelText("Image 图片")]
|
||||
[AddComponentMenu("YIUIBind/Data/图片 【Image】 UIDataBindImage")]
|
||||
public sealed class UIDataBindImage : UIDataBindSelectBase
|
||||
{
|
||||
[SerializeField] [ReadOnly] [Required("必须有此组件")] [LabelText("图片")]
|
||||
private Image m_Image;
|
||||
|
||||
[SerializeField] [LabelText("自动调整图像大小")]
|
||||
private bool m_SetNativeSize = false;
|
||||
|
||||
[SerializeField] [LabelText("可修改Enabled")]
|
||||
private bool m_ChangeEnabled = true;
|
||||
|
||||
private string m_LastSpriteName;
|
||||
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.String;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Image ??= GetComponent<Image>();
|
||||
if (!m_ChangeEnabled && !m_Image.enabled)
|
||||
{
|
||||
Logger.LogError($"{name} 当前禁止修改Enabled 且当前处于隐藏状态 可能会出现问题 请检查");
|
||||
}
|
||||
}
|
||||
|
||||
private void SetEnabled(bool set)
|
||||
{
|
||||
if (!m_ChangeEnabled) return;
|
||||
|
||||
if (m_Image == null) return;
|
||||
|
||||
m_Image.enabled = set;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (!UIOperationHelper.IsPlaying())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Image == null || gameObject == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<string>();
|
||||
|
||||
if (string.IsNullOrEmpty(dataValue))
|
||||
{
|
||||
SetEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ChangeSprite(dataValue).Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid ChangeSprite(string resName)
|
||||
{
|
||||
using var asyncLock = await AsyncLockMgr.Inst.Wait(GetHashCode());
|
||||
|
||||
if (m_LastSpriteName == resName)
|
||||
{
|
||||
if (m_Image != null && m_Image.sprite != null)
|
||||
{
|
||||
SetEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetEnabled(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ReleaseLastSprite();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!YIUILoadHelper.VerifyAssetValidity(resName))
|
||||
{
|
||||
Logger.LogError($"没有这个资源 图片无法加载 请检查 {resName}");
|
||||
SetEnabled(false);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
var sprite = await YIUILoadHelper.LoadAssetAsync<Sprite>(resName);
|
||||
|
||||
if (sprite == null)
|
||||
{
|
||||
Logger.LogError($"没有这个资源 图片无法加载 请检查 {resName}");
|
||||
SetEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameObject == null || m_Image == null)
|
||||
{
|
||||
YIUILoadHelper.Release(sprite);
|
||||
Logger.LogError($"{resName} 加载过程中 对象被摧毁了 gameObject == null || m_Image == null");
|
||||
return;
|
||||
}
|
||||
|
||||
m_LastSprite = sprite;
|
||||
m_Image.sprite = sprite;
|
||||
if (m_SetNativeSize)
|
||||
m_Image.SetNativeSize();
|
||||
|
||||
SetEnabled(true);
|
||||
m_LastSpriteName = resName;
|
||||
}
|
||||
|
||||
protected override void UnBindData()
|
||||
{
|
||||
base.UnBindData();
|
||||
if (!UIOperationHelper.IsPlaying())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ReleaseLastSprite();
|
||||
}
|
||||
|
||||
private Sprite m_LastSprite;
|
||||
|
||||
private void ReleaseLastSprite()
|
||||
{
|
||||
if (m_LastSprite != null)
|
||||
{
|
||||
YIUILoadHelper.Release(m_LastSprite);
|
||||
m_LastSprite = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1bc0d09ab654b1e86dae8222b40392d
|
||||
timeCreated: 1685418165
|
||||
@@ -0,0 +1,174 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using YIUIFramework;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[RequireComponent(typeof(Image))]
|
||||
[LabelText("ImageFill 图片填充")]
|
||||
[AddComponentMenu("YIUIBind/Data/图片填充 【ImageFill】 UIDataBindImageFill")]
|
||||
public sealed class UIDataBindImageFill : UIDataBindSelectBase
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("图片")]
|
||||
private Image m_Image;
|
||||
|
||||
[InfoBox(">0时 则设置值时会以动画的形式慢慢变化 需要运行时")]
|
||||
[SerializeField]
|
||||
[LabelText("动画速度")]
|
||||
#if UNITY_EDITOR
|
||||
[OnValueChanged("OnTweenSpeedValueChanged")]
|
||||
#endif
|
||||
private float m_TweenSpeed = 0.0f;
|
||||
|
||||
[SerializeField]
|
||||
private ETweenType m_TweenType = ETweenType.DoubleWay;
|
||||
|
||||
private float m_TargetValue;
|
||||
private bool m_PlayingTween = false;
|
||||
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Float;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Image ??= GetComponent<Image>();
|
||||
if (m_Image == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<float>();
|
||||
m_TargetValue = dataValue;
|
||||
m_Image.fillAmount = dataValue;
|
||||
m_PlayingTween = false;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Image == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<float>();
|
||||
if (m_TweenSpeed > 0.0f && Application.isPlaying)
|
||||
{
|
||||
m_TargetValue = dataValue;
|
||||
m_PlayingTween = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TargetValue = dataValue;
|
||||
m_Image.fillAmount = dataValue;
|
||||
m_PlayingTween = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnTweenSpeedValueChanged()
|
||||
{
|
||||
//如果突然吧动画速度改为0
|
||||
//且当前正在动画中 那么会错误 虽然只有editor才会出现
|
||||
//这里还是处理
|
||||
if (m_TweenSpeed <= 0)
|
||||
{
|
||||
if (!Mathf.Approximately(m_Image.fillAmount, m_TargetValue))
|
||||
{
|
||||
m_Image.fillAmount = m_TargetValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (m_PlayingTween &&
|
||||
m_TweenSpeed > 0.0f &&
|
||||
!Mathf.Approximately(m_Image.fillAmount, m_TargetValue))
|
||||
{
|
||||
switch (m_TweenType)
|
||||
{
|
||||
case ETweenType.IncreaseOnly:
|
||||
UpdateIncreaseOnly();
|
||||
break;
|
||||
case ETweenType.DecreaseOnly:
|
||||
UpdateDecreaseOnly();
|
||||
break;
|
||||
case ETweenType.DoubleWay:
|
||||
UpdateDoubleWay();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateIncreaseOnly()
|
||||
{
|
||||
if (m_TargetValue > m_Image.fillAmount)
|
||||
{
|
||||
UpdateDoubleWay();
|
||||
return;
|
||||
}
|
||||
|
||||
var movement = m_TweenSpeed * Time.deltaTime;
|
||||
var newValue = m_Image.fillAmount + movement;
|
||||
if (newValue >= 1)
|
||||
{
|
||||
m_Image.fillAmount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Image.fillAmount = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDecreaseOnly()
|
||||
{
|
||||
if (m_TargetValue < m_Image.fillAmount)
|
||||
{
|
||||
UpdateDoubleWay();
|
||||
return;
|
||||
}
|
||||
|
||||
var movement = m_TweenSpeed * Time.deltaTime;
|
||||
var newValue = m_Image.fillAmount - movement;
|
||||
if (newValue <= 0)
|
||||
{
|
||||
m_Image.fillAmount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Image.fillAmount = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDoubleWay()
|
||||
{
|
||||
var offset = m_TargetValue - m_Image.fillAmount;
|
||||
var movement = m_TweenSpeed * Time.deltaTime;
|
||||
if (movement > Mathf.Abs(offset))
|
||||
{
|
||||
m_Image.fillAmount = m_TargetValue;
|
||||
m_PlayingTween = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (offset > 0.0f)
|
||||
{
|
||||
m_Image.fillAmount += movement;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Image.fillAmount -= movement;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b263c64713c491b9e003ea83947de82
|
||||
timeCreated: 1706672744
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Others.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Others.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e60a045d68534c799340536b351c42ea
|
||||
timeCreated: 1688112680
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("下拉菜单")]
|
||||
[RequireComponent(typeof(Dropdown))]
|
||||
[AddComponentMenu("YIUIBind/Data/下拉菜单 【Dropdown】 UIDataBindDropdown")]
|
||||
public class UIDataBindDropdown : UIDataBindSelectBase
|
||||
{
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Int;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[SerializeField]
|
||||
[LabelText("下拉菜单")]
|
||||
private Dropdown m_Dropdown;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Dropdown ??= GetComponent<Dropdown>();
|
||||
if (m_Dropdown != null)
|
||||
{
|
||||
m_Dropdown.onValueChanged.RemoveListener(OnDropdownValueChanged);
|
||||
m_Dropdown.onValueChanged.AddListener(OnDropdownValueChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDropdownValueChanged(int index)
|
||||
{
|
||||
SetFirstValue<int>(index);
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Dropdown == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<int>();
|
||||
|
||||
if (m_Dropdown.value != dataValue)
|
||||
{
|
||||
m_Dropdown.value = dataValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a93cc933594a4cc5991301f97f4a800b
|
||||
timeCreated: 1681376113
|
||||
@@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("滚动条")]
|
||||
[RequireComponent(typeof(Scrollbar))]
|
||||
[AddComponentMenu("YIUIBind/Data/滚动条 【Scrollbar】 UIDataBindScrollbar")]
|
||||
public class UIDataBindScrollbar : UIDataBindSelectBase
|
||||
{
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[SerializeField]
|
||||
[LabelText("滚动条")]
|
||||
private Scrollbar m_Scrollbar;
|
||||
|
||||
[InfoBox(">0时 则设置值时会以动画的形式慢慢变化 需要运行时")]
|
||||
[SerializeField]
|
||||
[LabelText("滑动动画速度")]
|
||||
#if UNITY_EDITOR
|
||||
[OnValueChanged("OnTweenSpeedValueChanged")]
|
||||
#endif
|
||||
private float m_TweenSpeed = 0.0f;
|
||||
|
||||
[SerializeField]
|
||||
private ETweenType m_TweenType = ETweenType.DoubleWay;
|
||||
|
||||
private float m_TargetValue;
|
||||
private bool m_PlayingTween = false;
|
||||
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Float;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Scrollbar ??= GetComponent<Scrollbar>();
|
||||
if (m_Scrollbar == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<float>();
|
||||
m_TargetValue = dataValue;
|
||||
m_Scrollbar.value = dataValue;
|
||||
m_PlayingTween = false;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Scrollbar == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<float>();
|
||||
if (m_TweenSpeed > 0.0f && Application.isPlaying)
|
||||
{
|
||||
m_TargetValue = dataValue;
|
||||
m_PlayingTween = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TargetValue = dataValue;
|
||||
m_Scrollbar.value = dataValue;
|
||||
m_PlayingTween = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnTweenSpeedValueChanged()
|
||||
{
|
||||
//如果突然吧动画速度改为0
|
||||
//且当前正在动画中 那么会错误 虽然只有editor才会出现
|
||||
//这里还是处理
|
||||
if (m_TweenSpeed <= 0)
|
||||
{
|
||||
if (!Mathf.Approximately(m_Scrollbar.value, m_TargetValue))
|
||||
{
|
||||
m_Scrollbar.value = m_TargetValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (m_PlayingTween &&
|
||||
m_TweenSpeed > 0.0f &&
|
||||
!Mathf.Approximately(m_Scrollbar.value, m_TargetValue))
|
||||
{
|
||||
switch (m_TweenType)
|
||||
{
|
||||
case ETweenType.IncreaseOnly:
|
||||
UpdateIncreaseOnly();
|
||||
break;
|
||||
case ETweenType.DecreaseOnly:
|
||||
UpdateDecreaseOnly();
|
||||
break;
|
||||
case ETweenType.DoubleWay:
|
||||
UpdateDoubleWay();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateIncreaseOnly()
|
||||
{
|
||||
if (m_TargetValue > m_Scrollbar.value)
|
||||
{
|
||||
UpdateDoubleWay();
|
||||
return;
|
||||
}
|
||||
|
||||
var movement = m_TweenSpeed * Time.deltaTime;
|
||||
var newValue = m_Scrollbar.value + movement;
|
||||
if (newValue >= 1)
|
||||
{
|
||||
m_Scrollbar.value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Scrollbar.value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDecreaseOnly()
|
||||
{
|
||||
if (m_TargetValue < m_Scrollbar.value)
|
||||
{
|
||||
UpdateDoubleWay();
|
||||
return;
|
||||
}
|
||||
|
||||
var movement = m_TweenSpeed * Time.deltaTime;
|
||||
var newValue = m_Scrollbar.value - movement;
|
||||
if (newValue <= 0)
|
||||
{
|
||||
m_Scrollbar.value = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Scrollbar.value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDoubleWay()
|
||||
{
|
||||
var offset = m_TargetValue - m_Scrollbar.value;
|
||||
var movement = m_TweenSpeed * Time.deltaTime;
|
||||
if (movement > Mathf.Abs(offset))
|
||||
{
|
||||
m_Scrollbar.value = m_TargetValue;
|
||||
m_PlayingTween = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (offset > 0.0f)
|
||||
{
|
||||
m_Scrollbar.value += movement;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Scrollbar.value -= movement;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82cc7c557c96400db27c5e8dd5a912fb
|
||||
timeCreated: 1681390574
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[DetailedInfoBox("可选择的Toggle/Button ...类的",
|
||||
@"改变是否可触摸 Toggle / inputField / button / dropdown 这些都可以用
|
||||
在某些情况下不允许点击时 灰色点击那种 就可以用这个 因为他们都继承Selectable")]
|
||||
[RequireComponent(typeof(Selectable))]
|
||||
[LabelText("是否可选择")]
|
||||
[AddComponentMenu("YIUIBind/Data/交互 【Selectable】 UIDataBindSelectable")]
|
||||
public sealed class UIDataBindSelectable : UIDataBindBool
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("可选组件")]
|
||||
private Selectable m_Selectable;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Selectable ??= GetComponent<Selectable>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Selectable == null) return;
|
||||
|
||||
m_Selectable.interactable = GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1eb22435a89f4d6ca83e74eaf509ab6f
|
||||
timeCreated: 1681387112
|
||||
@@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[LabelText("滑动动画")]
|
||||
internal enum ETweenType
|
||||
{
|
||||
[LabelText("只增加")]
|
||||
IncreaseOnly,
|
||||
|
||||
[LabelText("只减少")]
|
||||
DecreaseOnly,
|
||||
|
||||
[LabelText("可双向增减")]
|
||||
DoubleWay,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[LabelText("滑块")]
|
||||
[RequireComponent(typeof(Slider))]
|
||||
[AddComponentMenu("YIUIBind/Data/滑块 【Slider】 UIDataBindSlider")]
|
||||
public class UIDataBindSlider : UIDataBindSelectBase
|
||||
{
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[SerializeField]
|
||||
[LabelText("滑块")]
|
||||
private Slider m_Slider;
|
||||
|
||||
[InfoBox(">0时 则设置值时会以动画的形式慢慢变化 需要运行时")]
|
||||
[SerializeField]
|
||||
[LabelText("滑动动画速度")]
|
||||
#if UNITY_EDITOR
|
||||
[OnValueChanged("OnTweenSpeedValueChanged")]
|
||||
#endif
|
||||
private float m_TweenSpeed = 0.0f;
|
||||
|
||||
[SerializeField]
|
||||
private ETweenType m_TweenType = ETweenType.DoubleWay;
|
||||
|
||||
private float m_TargetValue;
|
||||
private bool m_PlayingTween = false;
|
||||
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Float;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Slider ??= GetComponent<Slider>();
|
||||
if (m_Slider == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<float>();
|
||||
m_TargetValue = dataValue;
|
||||
m_Slider.value = dataValue;
|
||||
m_PlayingTween = false;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Slider == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<float>();
|
||||
if (m_TweenSpeed > 0.0f && Application.isPlaying)
|
||||
{
|
||||
m_TargetValue = dataValue;
|
||||
m_PlayingTween = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TargetValue = dataValue;
|
||||
m_Slider.value = dataValue;
|
||||
m_PlayingTween = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnTweenSpeedValueChanged()
|
||||
{
|
||||
//如果突然吧动画速度改为0
|
||||
//且当前正在动画中 那么会错误 虽然只有editor才会出现
|
||||
//这里还是处理
|
||||
if (m_TweenSpeed <= 0)
|
||||
{
|
||||
if (!Mathf.Approximately(m_Slider.value, m_TargetValue))
|
||||
{
|
||||
m_Slider.value = m_TargetValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (m_PlayingTween &&
|
||||
m_TweenSpeed > 0.0f &&
|
||||
!Mathf.Approximately(m_Slider.value, m_TargetValue))
|
||||
{
|
||||
switch (m_TweenType)
|
||||
{
|
||||
case ETweenType.IncreaseOnly:
|
||||
UpdateIncreaseOnly();
|
||||
break;
|
||||
case ETweenType.DecreaseOnly:
|
||||
UpdateDecreaseOnly();
|
||||
break;
|
||||
case ETweenType.DoubleWay:
|
||||
UpdateDoubleWay();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateIncreaseOnly()
|
||||
{
|
||||
if (m_TargetValue > m_Slider.value)
|
||||
{
|
||||
UpdateDoubleWay();
|
||||
return;
|
||||
}
|
||||
|
||||
var movement = m_TweenSpeed * Time.deltaTime;
|
||||
var newValue = m_Slider.value + movement;
|
||||
if (newValue >= m_Slider.maxValue)
|
||||
{
|
||||
m_Slider.value = m_Slider.minValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Slider.value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDecreaseOnly()
|
||||
{
|
||||
if (m_TargetValue < m_Slider.value)
|
||||
{
|
||||
UpdateDoubleWay();
|
||||
return;
|
||||
}
|
||||
|
||||
var movement = m_TweenSpeed * Time.deltaTime;
|
||||
var newValue = m_Slider.value - movement;
|
||||
if (newValue <= m_Slider.minValue)
|
||||
{
|
||||
m_Slider.value = m_Slider.maxValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Slider.value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDoubleWay()
|
||||
{
|
||||
var offset = m_TargetValue - m_Slider.value;
|
||||
var movement = m_TweenSpeed * Time.deltaTime;
|
||||
if (movement > Mathf.Abs(offset))
|
||||
{
|
||||
m_Slider.value = m_TargetValue;
|
||||
m_PlayingTween = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (offset > 0.0f)
|
||||
{
|
||||
m_Slider.value += movement;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Slider.value -= movement;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81b634efbcc3429a84079edb3735453d
|
||||
timeCreated: 1681389168
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[DetailedInfoBox("可选择的Toggle/Button ...类的",
|
||||
@"改变是否可触摸 Toggle / inputField / button / dropdown 这些都可以用
|
||||
在某些情况下不允许点击时 灰色点击那种 就可以用这个")]
|
||||
[RequireComponent(typeof(Toggle))]
|
||||
[LabelText("是否可选择")]
|
||||
[AddComponentMenu("YIUIBind/Data/开关 【Toggle】 UIDataBindSelectable")]
|
||||
public sealed class UIDataBindToggle : UIDataBindBool
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("开关")]
|
||||
private Toggle m_Toggle;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_Toggle ??= GetComponent<Toggle>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_Toggle == null) return;
|
||||
var result = GetResult();
|
||||
if (m_Toggle.isOn != result)
|
||||
{
|
||||
m_Toggle.isOn = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5232d3f797864c77ae40b4e60324998c
|
||||
timeCreated: 1681388225
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Rect.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Rect.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 846329bbd32c44d19defba6237f4133b
|
||||
timeCreated: 1685433444
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("UI位置")]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[AddComponentMenu("YIUIBind/Data/UI位置 【RectPos2】 UIDataBindRectPos2 s")]
|
||||
public class UIDataBindRectPos2 : UIDataBindSelectBase
|
||||
{
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Vector2;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("UI变换组件")]
|
||||
private RectTransform m_RectTransform;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("使用局部坐标否则世界坐标")]
|
||||
private bool m_LocalPosition = true;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_RectTransform ??= GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_RectTransform == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<Vector2>();
|
||||
|
||||
if (m_LocalPosition)
|
||||
{
|
||||
m_RectTransform.localPosition = dataValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RectTransform.position = dataValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4950164191a4d09aad5da98d788dedf
|
||||
timeCreated: 1681457903
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("UI位置")]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[AddComponentMenu("YIUIBind/Data/UI位置 【RectPos3】 UIDataBindRectPos3 y")]
|
||||
public class UIDataBindRectPos3 : UIDataBindSelectBase
|
||||
{
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Vector3;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("UI变换组件")]
|
||||
private RectTransform m_RectTransform;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("使用局部坐标否则世界坐标")]
|
||||
private bool m_LocalPosition = true;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_RectTransform ??= GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_RectTransform == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<Vector3>();
|
||||
|
||||
if (m_LocalPosition)
|
||||
{
|
||||
m_RectTransform.localPosition = dataValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RectTransform.position = dataValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b285761ac994ea1a2878b189509c2a5
|
||||
timeCreated: 1681458168
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("UI旋转")]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[AddComponentMenu("YIUIBind/Data/UI旋转 【RectRot1】 UIDataBindRectRot1 l")]
|
||||
public class UIDataBindRectRot1 : UIDataBindSelectBase
|
||||
{
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Float;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("UI变换组件")]
|
||||
private RectTransform m_RectTransform;
|
||||
|
||||
[SerializeField]
|
||||
[InfoBox("那个轴有值就是控制那个轴 单位1, 多的就是倍数 默认使用 Z轴旋转1")]
|
||||
[LabelText("目标轴")]
|
||||
private Vector3 m_TargetRot = Vector3.forward;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_RectTransform ??= GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_RectTransform == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<float>();
|
||||
|
||||
m_RectTransform.rotation = Quaternion.Euler(m_TargetRot * dataValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 197a55233202422e882710595998151d
|
||||
timeCreated: 1681458697
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("UI旋转")]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[AddComponentMenu("YIUIBind/Data/UI旋转 【RectRot3】 UIDataBindRectRot3")]
|
||||
public class UIDataBindRectRot3 : UIDataBindSelectBase
|
||||
{
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Vector3;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("UI变换组件")]
|
||||
private RectTransform m_RectTransform;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_RectTransform ??= GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_RectTransform == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<Vector3>();
|
||||
|
||||
m_RectTransform.rotation = Quaternion.Euler(dataValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d7a48e1c49746cf90acbd940cd806e7
|
||||
timeCreated: 1681458480
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("UI缩放")]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[AddComponentMenu("YIUIBind/Data/UI缩放 【RectScale1】 UIDataBindRectScale1")]
|
||||
public class UIDataBindRectScale1 : UIDataBindSelectBase
|
||||
{
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Float;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("UI变换组件")]
|
||||
private RectTransform m_RectTransform;
|
||||
|
||||
[SerializeField]
|
||||
[InfoBox("那个轴有值就是控制那个轴 单位1, 多的就是倍数 默认使用 Z轴旋转1")]
|
||||
[LabelText("目标轴")]
|
||||
private Vector3 m_Target = Vector3.right;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_RectTransform ??= GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_RectTransform == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<float>();
|
||||
|
||||
m_RectTransform.localScale = m_Target * dataValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 178adc740a8b4b8d84744e7958be00c6
|
||||
timeCreated: 1681459428
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("UI缩放")]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[AddComponentMenu("YIUIBind/Data/UI缩放 【RectScale3】 UIDataBindRectScale3")]
|
||||
public class UIDataBindRectScale3 : UIDataBindSelectBase
|
||||
{
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Vector3;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("UI变换组件")]
|
||||
private RectTransform m_RectTransform;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_RectTransform ??= GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_RectTransform == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<Vector3>();
|
||||
|
||||
m_RectTransform.localScale = dataValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f0f5c3a5d2e4cdd8c5948615073d1b1
|
||||
timeCreated: 1681459359
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[Serializable]
|
||||
[LabelText("UI大小")]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[AddComponentMenu("YIUIBind/Data/UI大小 【RectSize】 UIDataBindRectSize")]
|
||||
public class UIDataBindRectSize : UIDataBindSelectBase
|
||||
{
|
||||
protected override int Mask()
|
||||
{
|
||||
return 1 << (int)EUIBindDataType.Vector2;
|
||||
}
|
||||
|
||||
protected override int SelectMax()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("UI变换组件")]
|
||||
private RectTransform m_RectTransform;
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
m_RectTransform ??= GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (m_RectTransform == null) return;
|
||||
|
||||
var dataValue = GetFirstValue<Vector2>();
|
||||
m_RectTransform.sizeDelta = dataValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84a972e5e1a940dea1506735c21a36f9
|
||||
timeCreated: 1681444764
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Text.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Data/Text.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 793c425151604936ae7798b9b0793589
|
||||
timeCreated: 1685615983
|
||||
@@ -0,0 +1,55 @@
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[RequireComponent(typeof(Text))]
|
||||
[LabelText("Text 文本")]
|
||||
[AddComponentMenu("YIUIBind/Data/文本 【Text】 UIDataBindText")]
|
||||
public sealed class UIDataBindText : UIDataBindTextBase
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("文本")]
|
||||
private Text m_Text;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
m_Text ??= GetComponent<Text>();
|
||||
if (m_Text == null)
|
||||
{
|
||||
Logger.LogError($"{name} 错误没有 Text 组件");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_ChangeEnabled && !m_Text.enabled)
|
||||
{
|
||||
Logger.LogError($"{name} 当前文本禁止修改Enabled 且当前处于隐藏状态 可能会出现问题 请检查");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetEnabled(bool value)
|
||||
{
|
||||
if (m_Text == null) return;
|
||||
m_Text.enabled = value;
|
||||
}
|
||||
|
||||
protected override void SetText(string value)
|
||||
{
|
||||
m_Text.text = value;
|
||||
}
|
||||
|
||||
protected override bool ExistText()
|
||||
{
|
||||
if (m_Text == null)
|
||||
{
|
||||
m_Text = GetComponent<Text>();
|
||||
}
|
||||
|
||||
return m_Text != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d3ccfbae51b43709e508ebe14fffd96
|
||||
timeCreated: 1679059673
|
||||
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 文本数据修改 基类
|
||||
/// </summary>
|
||||
public abstract class UIDataBindTextBase : UIDataBindSelectBase
|
||||
{
|
||||
[SerializeField]
|
||||
[Delayed] //延迟序列化
|
||||
[TextArea(2, 10)]
|
||||
[LabelText("字符串填充{0}{1}形式")]
|
||||
protected string m_Format;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("可修改Enabled")]
|
||||
protected bool m_ChangeEnabled = true;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("数字精度")]
|
||||
protected bool m_NumberPrecision = false;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("精度值")]
|
||||
[ShowIf("m_NumberPrecision")]
|
||||
protected string m_NumberPrecisionStr = "F1";
|
||||
|
||||
protected override int Mask()
|
||||
{
|
||||
return -1; //允许任何数据 只要你吧tostring写清楚就行
|
||||
}
|
||||
|
||||
protected override void OnRefreshData()
|
||||
{
|
||||
base.OnRefreshData();
|
||||
OnInit();
|
||||
}
|
||||
|
||||
private void BaseSetEnabled(bool set)
|
||||
{
|
||||
if (!m_ChangeEnabled) return;
|
||||
SetEnabled(set);
|
||||
}
|
||||
|
||||
private object[] m_ParamList;
|
||||
|
||||
/// <summary>
|
||||
/// 当有format时 多参数就会生效依次填充
|
||||
/// 否则只会使用第一个值
|
||||
/// </summary>
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (!ExistText()) return;
|
||||
|
||||
if (DataSelectDic == null || DataSelectDic.Count <= 0)
|
||||
{
|
||||
BaseSetEnabled(false);
|
||||
SetText("");
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(m_Format))
|
||||
{
|
||||
var data = DataSelectDic.First().Value;
|
||||
var value = GetDataToString(data);
|
||||
BaseSetEnabled(!string.IsNullOrEmpty(value));
|
||||
SetText(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_ParamList == null || m_ParamList.Length != DataSelectDic.Count)
|
||||
{
|
||||
m_ParamList = new object[DataSelectDic.Count];
|
||||
}
|
||||
|
||||
var index = -1;
|
||||
foreach (var dataSelect in DataSelectDic.Values)
|
||||
{
|
||||
index++;
|
||||
m_ParamList[index] = GetDataToString(dataSelect);
|
||||
}
|
||||
|
||||
BaseSetEnabled(true);
|
||||
|
||||
try
|
||||
{
|
||||
SetText(string.Format(m_Format, m_ParamList));
|
||||
}
|
||||
catch (FormatException exp)
|
||||
{
|
||||
Logger.LogError($"{name} 字符串拼接Format 出错请检查是否有拼写错误 {m_Format}");
|
||||
Logger.LogError(exp.Message, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetDataToString(UIDataSelect dataSelect)
|
||||
{
|
||||
var dataValue = dataSelect?.Data?.DataValue;
|
||||
if (dataValue == null) return "";
|
||||
|
||||
//如果不想用现在数据重写的tostring 可以在本类自行额外解析法
|
||||
if (!m_NumberPrecision) return dataValue.GetValueToString();
|
||||
|
||||
switch (dataValue.UIBindDataType)
|
||||
{
|
||||
case EUIBindDataType.Float:
|
||||
return dataValue.GetValue<float>().ToString(m_NumberPrecisionStr);
|
||||
case EUIBindDataType.Double:
|
||||
return dataValue.GetValue<double>().ToString(m_NumberPrecisionStr);
|
||||
default:
|
||||
return dataValue.GetValueToString();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void OnInit();
|
||||
protected abstract void SetEnabled(bool value);
|
||||
protected abstract void SetText(string value);
|
||||
protected abstract bool ExistText();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a253825fd874975bc1bf1e5467eaf49
|
||||
timeCreated: 1685615996
|
||||
@@ -0,0 +1,55 @@
|
||||
using Sirenix.OdinInspector;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[RequireComponent(typeof(TextMeshProUGUI))]
|
||||
[LabelText("Text 文本TMP")]
|
||||
[AddComponentMenu("YIUIBind/Data/文本TMP 【TextTMP】 UIDataBindTextTMP")]
|
||||
public sealed class UIDataBindTextTMP : UIDataBindTextBase
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("文本")]
|
||||
private TextMeshProUGUI m_Text;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
m_Text ??= GetComponent<TextMeshProUGUI>();
|
||||
if (m_Text == null)
|
||||
{
|
||||
Logger.LogError($"{name} 错误没有 Text 组件");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_ChangeEnabled && !m_Text.enabled)
|
||||
{
|
||||
Logger.LogError($"{name} 当前文本禁止修改Enabled 且当前处于隐藏状态 可能会出现问题 请检查");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetEnabled(bool value)
|
||||
{
|
||||
if (m_Text == null) return;
|
||||
m_Text.enabled = value;
|
||||
}
|
||||
|
||||
protected override void SetText(string value)
|
||||
{
|
||||
m_Text.text = value;
|
||||
}
|
||||
|
||||
protected override bool ExistText()
|
||||
{
|
||||
if (m_Text == null)
|
||||
{
|
||||
m_Text = GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
return m_Text != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ea8275b4f0f472ea55d9dfdae6c6d8c
|
||||
timeCreated: 1685607861
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Event.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Event.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb94b56d43c544d880111d5c849d4a2d
|
||||
timeCreated: 1681370090
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Event/Active.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Event/Active.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4fdcbfafdf44fdf8d6ae400f782e0d5
|
||||
timeCreated: 1688112702
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[InfoBox("提示: 可用事件参数 <参数1:Unity.GameObj(被控制的对象),bool(激活状态)>")]
|
||||
[LabelText("显隐<Unity.GameObj,bool>")]
|
||||
[AddComponentMenu("YIUIBind/Event/显隐 【Active】 UIEventBindActive")]
|
||||
public class UIEventBindActive : UIEventBind
|
||||
{
|
||||
protected override bool IsTaskEvent => false;
|
||||
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
EUIEventParamType.UnityGameObject,
|
||||
EUIEventParamType.Bool,
|
||||
};
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIEvent?.Invoke(gameObject, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIEvent?.Invoke(gameObject, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d72addf90dd048a3b0781701a3bd37c8
|
||||
timeCreated: 1681703118
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3a5a8a3dfe2488b8004a99e8cf15842
|
||||
timeCreated: 1688112715
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击事件绑定
|
||||
/// 与按钮无关
|
||||
/// 只要是任何可以被射线检测的物体都可以响应点击事件
|
||||
/// </summary>
|
||||
[InfoBox("提示: 可用事件参数 0个")]
|
||||
[LabelText("数据改变<null>")]
|
||||
[AddComponentMenu("YIUIBind/Event/数据改变 【ChangeDataValue】 UIEventBindChangeDataValue")]
|
||||
[RequireComponent(typeof(UIDataBindChange))]
|
||||
public class UIEventBindChangeDataValue : UIEventBind
|
||||
{
|
||||
protected override bool IsTaskEvent => false;
|
||||
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
private UIDataBindChange m_UIDataBindChange;
|
||||
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
};
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
InitBindChange();
|
||||
}
|
||||
|
||||
private void InitBindChange()
|
||||
{
|
||||
m_UIDataBindChange ??= GetComponent<UIDataBindChange>();
|
||||
if (m_UIDataBindChange != null)
|
||||
{
|
||||
m_UIDataBindChange.AddChangeAction(OnChangeDataValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnChangeDataValue()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIEvent?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private new void OnDestroy()
|
||||
{
|
||||
if (m_UIDataBindChange != null)
|
||||
{
|
||||
m_UIDataBindChange.RemoveChangeAction(OnChangeDataValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f6e90576ff200f489e80e251baaeca2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Event/Click.meta
vendored
Normal file
8
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Event/Click.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e3776bfc534c104a8e22e3f1112b6b7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72db1bca9eb14846aebc883f288af741
|
||||
timeCreated: 1732874557
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using YIUIFramework;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击事件绑定
|
||||
/// 与按钮无关
|
||||
/// 只要是任何可以被射线检测的物体都可以响应点击事件
|
||||
/// </summary>
|
||||
[LabelText("点击<null>")]
|
||||
[AddComponentMenu("YIUIBind/TaskEvent/点击 【Click】 UITaskEventBindClick")]
|
||||
public class UITaskEventBindClick : UIEventBind, IPointerClickHandler
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("拖拽时不响应点击")]
|
||||
private bool m_SkipWhenDrag;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("可选组件")]
|
||||
private Selectable m_Selectable;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("响应中 屏蔽所有操作")]
|
||||
private bool m_BanLayerOption = true;
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (m_Selectable != null && !m_Selectable.interactable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_SkipWhenDrag && eventData.dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ClickTasking) return;
|
||||
|
||||
TaskEvent(eventData).Forget();
|
||||
}
|
||||
|
||||
protected override bool IsTaskEvent => true;
|
||||
|
||||
[NonSerialized]
|
||||
private List<EUIEventParamType> m_BaseFilterParamType = new List<EUIEventParamType> { };
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_BaseFilterParamType;
|
||||
}
|
||||
|
||||
[NonSerialized]
|
||||
protected bool ClickTasking; //异步中
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_Selectable ??= GetComponent<Selectable>();
|
||||
ClickTasking = false;
|
||||
}
|
||||
|
||||
protected async UniTask TaskEvent(PointerEventData eventData)
|
||||
{
|
||||
if (m_UIEvent == null) return;
|
||||
var banLayerCode = 0;
|
||||
if (m_BanLayerOption)
|
||||
{
|
||||
banLayerCode = PanelMgr.Inst.BanLayerOptionForever();
|
||||
}
|
||||
|
||||
ClickTasking = true;
|
||||
|
||||
try
|
||||
{
|
||||
await OnUIEvent(eventData);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
ClickTasking = false;
|
||||
|
||||
if (m_BanLayerOption)
|
||||
{
|
||||
PanelMgr.Inst.RecoverLayerOptionForever(banLayerCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual async UniTask OnUIEvent(PointerEventData eventData)
|
||||
{
|
||||
await m_UIEvent.InvokeAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 543b9965e22a4bb882ba1493143e19f2
|
||||
timeCreated: 1698505735
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击事件绑定
|
||||
/// 与按钮无关
|
||||
/// 只要是任何可以被射线检测的物体都可以响应点击事件
|
||||
/// 额外多一个int 参数自定义
|
||||
/// </summary>
|
||||
[InfoBox("提示: 可用事件参数 1个")]
|
||||
[LabelText("点击<int>")]
|
||||
[AddComponentMenu("YIUIBind/TaskEvent/点击 【Click Int】 UITaskEventBindClickInt")]
|
||||
public class UITaskEventBindClickInt : UITaskEventBindClick
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("额外int参数值")]
|
||||
private int m_ExtraParam;
|
||||
|
||||
[NonSerialized]
|
||||
private List<EUIEventParamType> m_BaseFilterParamType = new List<EUIEventParamType> { EUIEventParamType.Int };
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_BaseFilterParamType;
|
||||
}
|
||||
|
||||
protected override async UniTask OnUIEvent(PointerEventData eventData)
|
||||
{
|
||||
await m_UIEvent.InvokeAsync(m_ExtraParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 342e6d62517e48b99c08f29931bfe0c8
|
||||
timeCreated: 1698507162
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击事件绑定
|
||||
/// 与按钮无关
|
||||
/// 只要是任何可以被射线检测的物体都可以响应点击事件
|
||||
/// </summary>
|
||||
[InfoBox("提示: 可用事件参数 1个 , Object(PointerEventData)")]
|
||||
[LabelText("点击<PointerEventData>")]
|
||||
[AddComponentMenu("YIUIBind/TaskEvent/点击 【ClickPointerEventData】 UITaskEventBindClickPointerEventData")]
|
||||
public class UITaskEventBindClickPointerEventData : UITaskEventBindClick
|
||||
{
|
||||
[NonSerialized]
|
||||
private List<EUIEventParamType> m_BaseFilterParamType = new List<EUIEventParamType> { EUIEventParamType.Object };
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_BaseFilterParamType;
|
||||
}
|
||||
|
||||
protected override async UniTask OnUIEvent(PointerEventData eventData)
|
||||
{
|
||||
//额外添加 如果想要这个点击事件 使用此监听
|
||||
//响应方法那边参数是obj 自己在转一次 没有扩展这个参数 因为没必要
|
||||
await m_UIEvent.InvokeAsync(eventData as object);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b293d3082dd46978a47fbcf7e6ed9ee
|
||||
timeCreated: 1698507252
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击事件绑定
|
||||
/// 与按钮无关
|
||||
/// 只要是任何可以被射线检测的物体都可以响应点击事件
|
||||
/// 额外多一个String 参数自定义
|
||||
/// </summary>
|
||||
[InfoBox("提示: 可用事件参数 1个")]
|
||||
[LabelText("点击<String>")]
|
||||
[AddComponentMenu("YIUIBind/TaskEvent/点击 【Click String】 UITaskEventBindClickString")]
|
||||
public class UITaskEventBindClickString : UITaskEventBindClick
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("额外string参数值")]
|
||||
private string m_ExtraParam;
|
||||
|
||||
[NonSerialized]
|
||||
private List<EUIEventParamType> m_BaseFilterParamType = new List<EUIEventParamType> { EUIEventParamType.String };
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_BaseFilterParamType;
|
||||
}
|
||||
|
||||
protected override async UniTask OnUIEvent(PointerEventData eventData)
|
||||
{
|
||||
await m_UIEvent.InvokeAsync(m_ExtraParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b243fbb52c214de192dfbdbe7f7b4ceb
|
||||
timeCreated: 1698507295
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击事件绑定
|
||||
/// 与按钮无关
|
||||
/// 只要是任何可以被射线检测的物体都可以响应点击事件
|
||||
/// </summary>
|
||||
[LabelText("点击<null>")]
|
||||
[AddComponentMenu("YIUIBind/Event/点击 【Click】 UIEventBindClick")]
|
||||
public class UIEventBindClick : UIEventBind, IPointerClickHandler
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("拖拽时不响应点击")]
|
||||
private bool m_SkipWhenDrag;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("可选组件")]
|
||||
private Selectable m_Selectable;
|
||||
|
||||
protected override bool IsTaskEvent => false;
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (m_Selectable != null && !m_Selectable.interactable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_SkipWhenDrag && eventData.dragging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OnUIEvent(eventData);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private List<EUIEventParamType> m_BaseFilterParamType = new List<EUIEventParamType> { };
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_BaseFilterParamType;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_Selectable ??= GetComponent<Selectable>();
|
||||
}
|
||||
|
||||
protected virtual void OnUIEvent(PointerEventData eventData)
|
||||
{
|
||||
m_UIEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b84c394472d09c84a9af3111a280f2eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击事件绑定
|
||||
/// 与按钮无关
|
||||
/// 只要是任何可以被射线检测的物体都可以响应点击事件
|
||||
/// 额外多一个int 参数自定义
|
||||
/// </summary>
|
||||
[InfoBox("提示: 可用事件参数 1个")]
|
||||
[LabelText("点击<int>")]
|
||||
[AddComponentMenu("YIUIBind/Event/点击 【Click Int】 UIEventBindClickInt")]
|
||||
public class UIEventBindClickInt : UIEventBindClick
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("额外int参数值")]
|
||||
private int m_ExtraParam;
|
||||
|
||||
[NonSerialized]
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
EUIEventParamType.Int,
|
||||
};
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
protected override void OnUIEvent(PointerEventData eventData)
|
||||
{
|
||||
m_UIEvent?.Invoke(m_ExtraParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5488bc7e88164cdebc6f8149d95a955d
|
||||
timeCreated: 1688020668
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击事件绑定
|
||||
/// 与按钮无关
|
||||
/// 只要是任何可以被射线检测的物体都可以响应点击事件
|
||||
/// </summary>
|
||||
[InfoBox("提示: 可用事件参数 1个 , Object(PointerEventData)")]
|
||||
[LabelText("点击<PointerEventData>")]
|
||||
[AddComponentMenu("YIUIBind/Event/点击 【ClickPointerEventData】 UIEventBindClickPointerEventData")]
|
||||
public class UIEventBindClickPointerEventData : UIEventBindClick
|
||||
{
|
||||
[NonSerialized]
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
EUIEventParamType.Object,
|
||||
};
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
protected override void OnUIEvent(PointerEventData eventData)
|
||||
{
|
||||
//额外添加 如果想要这个点击事件 使用此监听
|
||||
//响应方法那边参数是obj 自己在转一次 没有扩展这个参数 因为没必要
|
||||
m_UIEvent?.Invoke(eventData as object);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93448753a58d4c3f8f9304cb8cfacc97
|
||||
timeCreated: 1681225251
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击事件绑定
|
||||
/// 与按钮无关
|
||||
/// 只要是任何可以被射线检测的物体都可以响应点击事件
|
||||
/// 额外多一个String 参数自定义
|
||||
/// </summary>
|
||||
[InfoBox("提示: 可用事件参数 1个")]
|
||||
[LabelText("点击<String>")]
|
||||
[AddComponentMenu("YIUIBind/Event/点击 【Click String】 UIEventBindClickString")]
|
||||
public class UIEventBindClickString : UIEventBindClick
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("额外string参数值")]
|
||||
private string m_ExtraParam;
|
||||
|
||||
[NonSerialized]
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
EUIEventParamType.String,
|
||||
};
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
protected override void OnUIEvent(PointerEventData eventData)
|
||||
{
|
||||
m_UIEvent?.Invoke(m_ExtraParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6c39285dc12489e8ed800d950b32b26
|
||||
timeCreated: 1688020870
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5c2c91107eb3fe43b10ae4c58a5e5fa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[InfoBox("提示: 可用事件参数 <参数1:int(下拉菜单被选择的索引值)>")]
|
||||
[LabelText("下拉菜单<int>")]
|
||||
[RequireComponent(typeof(Dropdown))]
|
||||
[AddComponentMenu("YIUIBind/Event/下拉菜单 【Dropdown】 UIEventBindDropdown")]
|
||||
public class UIEventBindDropdown : UIEventBind
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("下拉菜单")]
|
||||
private Dropdown m_Dropdown;
|
||||
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
EUIEventParamType.Int
|
||||
};
|
||||
|
||||
protected override bool IsTaskEvent => false;
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_Dropdown ??= GetComponent<Dropdown>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_Dropdown.onValueChanged.AddListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
m_Dropdown.onValueChanged.RemoveListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnValueChanged(int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIEvent?.Invoke(value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 779b7f60021be164b904de69e0a5b462
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[InfoBox("提示: 可用事件参数 <参数1:int(下拉菜单被选择的索引值)>")]
|
||||
[LabelText("下拉菜单<int>")]
|
||||
[RequireComponent(typeof(TMP_Dropdown))]
|
||||
[AddComponentMenu("YIUIBind/Event/下拉菜单 【Dropdown TMP】 UIEventBindDropdownTMP")]
|
||||
public class UIEventBindDropdownTMP : UIEventBind
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("下拉菜单")]
|
||||
private TMP_Dropdown m_Dropdown;
|
||||
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
EUIEventParamType.Int
|
||||
};
|
||||
|
||||
protected override bool IsTaskEvent => false;
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_Dropdown ??= GetComponent<TMP_Dropdown>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_Dropdown.onValueChanged.AddListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
m_Dropdown.onValueChanged.RemoveListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnValueChanged(int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIEvent?.Invoke(value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9dd74c366fc54ef59cdad91b955e52c1
|
||||
timeCreated: 1687160298
|
||||
8
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Event/Input.meta
vendored
Normal file
8
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBind/Extend/Event/Input.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 207c70d4d57af3b439c1e38b70c36c23
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[InfoBox("提示: 可用事件参数 <参数1:string(输入的值)>")]
|
||||
[LabelText("输入栏<string> 变化时")]
|
||||
[RequireComponent(typeof(InputField))]
|
||||
[AddComponentMenu("YIUIBind/Event/输入栏 【InputField】 UIEventBindInputField")]
|
||||
public class UIEventBindInputField : UIEventBind
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("输入栏")]
|
||||
private InputField m_InputField;
|
||||
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
EUIEventParamType.String
|
||||
};
|
||||
|
||||
protected override bool IsTaskEvent => false;
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_InputField ??= GetComponent<InputField>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_InputField.onValueChanged.AddListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
m_InputField.onValueChanged.RemoveListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnValueChanged(string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIEvent?.Invoke(value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f49dfb92d9da4393acabb0e020fa4532
|
||||
timeCreated: 1681712010
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[InfoBox("提示: 可用事件参数 <参数1:string(输入的值)>")]
|
||||
[LabelText("输入栏<string> 结束时")]
|
||||
[RequireComponent(typeof(InputField))]
|
||||
[AddComponentMenu("YIUIBind/Event/输入栏 【InputFieldEnd】 UIEventBindInputFieldEnd")]
|
||||
public class UIEventBindInputFieldEnd : UIEventBind
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("输入栏")]
|
||||
private InputField m_InputField;
|
||||
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
EUIEventParamType.String
|
||||
};
|
||||
|
||||
protected override bool IsTaskEvent => false;
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_InputField ??= GetComponent<InputField>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_InputField.onEndEdit.AddListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
m_InputField.onEndEdit.RemoveListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnValueChanged(string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIEvent?.Invoke(value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8cae0be758dd43eda4c30a94f781b3e2
|
||||
timeCreated: 1681712670
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Logger = YIUIFramework.Logger;
|
||||
|
||||
namespace YIUIBind
|
||||
{
|
||||
[InfoBox("提示: 可用事件参数 <参数1:string(输入的值)>")]
|
||||
[LabelText("输入栏<string> 结束时")]
|
||||
[RequireComponent(typeof(TMP_InputField))]
|
||||
[AddComponentMenu("YIUIBind/Event/输入栏 【InputFieldEnd TMP】 UIEventBindInputFieldEndTMP")]
|
||||
public class UIEventBindInputFieldEndTMP : UIEventBind
|
||||
{
|
||||
[SerializeField]
|
||||
[ReadOnly]
|
||||
[Required("必须有此组件")]
|
||||
[LabelText("输入栏")]
|
||||
private TMP_InputField m_InputField;
|
||||
|
||||
private List<EUIEventParamType> m_FilterParamType = new List<EUIEventParamType>
|
||||
{
|
||||
EUIEventParamType.String
|
||||
};
|
||||
|
||||
protected override bool IsTaskEvent => false;
|
||||
|
||||
protected override List<EUIEventParamType> GetFilterParamType()
|
||||
{
|
||||
return m_FilterParamType;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_InputField ??= GetComponent<TMP_InputField>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_InputField.onEndEdit.AddListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
m_InputField.onEndEdit.RemoveListener(OnValueChanged);
|
||||
}
|
||||
|
||||
private void OnValueChanged(string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIEvent?.Invoke(value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user