添加unity容器类,允许使用泛型控制界面上的值。
目前添加了一次最多三个项目的属性。
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8214816258e04879be55e0e4bbfc6e71
|
||||
timeCreated: 1753256011
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace XericUI.Core.Base
|
||||
{
|
||||
public class XericUIBehaciour : UIBehaviour
|
||||
{
|
||||
[InfoBox("脚本属性存在空引用!请检查开放属性后再试", InfoMessageType.Error, VisibleIf = "PublicFieldNullReference")]
|
||||
[HideLabel, DisplayAsString]
|
||||
string __EMPTYFIELD;
|
||||
|
||||
|
||||
protected bool PublicFieldNullReference;
|
||||
|
||||
protected bool AlreadyAwake { get; private set; }
|
||||
protected bool AlreadyStart { get; private set; }
|
||||
protected bool AlreadyOnEnable { get; private set; }
|
||||
protected bool AlreadyOnDisable { get; private set; }
|
||||
protected bool FirstUpdate { get; private set; }
|
||||
protected bool FirstFixUpdate { get; private set; }
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
AlreadyAwake = true;
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
AlreadyStart = true;
|
||||
base.Start();
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
AlreadyOnEnable = true;
|
||||
base.OnEnable();
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
AlreadyOnDisable = true;
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c86649055e4243d69a945bf7f6a4d474
|
||||
timeCreated: 1753256057
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c397c88f8834566bf6ba98d579f4db1
|
||||
timeCreated: 1753253292
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace XericUI.Core.Vessel
|
||||
{
|
||||
/// <summary>
|
||||
/// 组件界面泛型容器
|
||||
/// 详情参阅Xeric Library本体库Wiki中关于组件容器的说明。
|
||||
/// </summary>
|
||||
/// <typeparam name="T0"></typeparam>
|
||||
[Serializable]
|
||||
public class ObjectVessel<T0> : VesselBase
|
||||
where T0 : Object
|
||||
{
|
||||
[SerializeField]
|
||||
private Object target = default(T0);
|
||||
|
||||
/// <summary>
|
||||
/// 获取此包裹器中的
|
||||
/// </summary>
|
||||
public T0 Target
|
||||
{
|
||||
get => target as T0;
|
||||
set => target = value;
|
||||
}
|
||||
|
||||
public ObjectVessel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ObjectVessel(Object target)
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00f4d38097bf40e99b75ab7d431ec126
|
||||
timeCreated: 1753253311
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace XericUI.Core.Vessel
|
||||
{
|
||||
[Serializable]
|
||||
public class ObjectVessel<T0, T1> : VesselBase
|
||||
where T0 : Object
|
||||
where T1 : Object
|
||||
{
|
||||
[SerializeField] private Object target0 = default(T0);
|
||||
[SerializeField] private Object target1 = default(T1);
|
||||
|
||||
public T0 Target0
|
||||
{
|
||||
get => target0 as T0;
|
||||
set => target0 = value;
|
||||
}
|
||||
public T1 Target1
|
||||
{
|
||||
get => target1 as T1;
|
||||
set => target1 = value;
|
||||
}
|
||||
|
||||
|
||||
public ObjectVessel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ObjectVessel(Object target0, Object target1)
|
||||
{
|
||||
this.target0 = target0;
|
||||
this.target1 = target1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f9ea9e74d6c4f8ea55cda5d419fa6f0
|
||||
timeCreated: 1753260697
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace XericUI.Core.Vessel
|
||||
{
|
||||
[Serializable]
|
||||
public class ObjectVessel<T0, T1, T2> : VesselBase
|
||||
where T0 : Object
|
||||
where T1 : Object
|
||||
where T2 : Object
|
||||
{
|
||||
[SerializeField] private Object target0 = default(T0);
|
||||
[SerializeField] private Object target1 = default(T1);
|
||||
[SerializeField] private Object target2 = default(T2);
|
||||
|
||||
public T0 Target0
|
||||
{
|
||||
get => target0 as T0;
|
||||
set => target0 = value;
|
||||
}
|
||||
public T1 Target1
|
||||
{
|
||||
get => target1 as T1;
|
||||
set => target1 = value;
|
||||
}
|
||||
public T2 Target2
|
||||
{
|
||||
get => target2 as T2;
|
||||
set => target2 = value;
|
||||
}
|
||||
|
||||
|
||||
public ObjectVessel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ObjectVessel(Object target0, Object target1, Object target2)
|
||||
{
|
||||
this.target0 = target0;
|
||||
this.target1 = target1;
|
||||
this.target2 = target2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd442520699543d4a376fff5bb1c7779
|
||||
timeCreated: 1753263701
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace XericUI.Core.Vessel
|
||||
{
|
||||
public class VesselBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1ebb22ea2ec4d32b41608c8c1777ada
|
||||
timeCreated: 1753254327
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using XericUI.Core.Vessel;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XericUI.Core.Text
|
||||
{
|
||||
public static partial class XericUIExtendHelper
|
||||
{
|
||||
public static string DebugSelfName => "<TextMeshPro>";
|
||||
|
||||
#region TMP_Text
|
||||
|
||||
/// <summary>
|
||||
/// 获取文本容器中的字符串内容
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetStringContext<T>(this ObjectVessel<T> obj)
|
||||
where T : TMP_Text
|
||||
=> obj != null ? obj.Target.text : string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取文本容器中的字符串内容
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static void SetStringContext<T>(this ObjectVessel<T> obj, string value)
|
||||
where T : TMP_Text
|
||||
{
|
||||
if (obj != null)
|
||||
obj.Target.text = value;
|
||||
else
|
||||
Debug.LogError($"正在向空{DebugSelfName}对象赋值");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1739fa9e30fc4e0a80b97feea7d930b5
|
||||
timeCreated: 1753242867
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericUI.Core.Vessel
|
||||
{
|
||||
public static partial class XericUIExtendHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 检查容器有效
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <typeparam name="T0"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid<T0>(this ObjectVessel<T0> obj)
|
||||
where T0 : Object
|
||||
=> obj != null && obj.Target != null;
|
||||
/// <summary>
|
||||
/// 检查容器有效
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <typeparam name="T0"></typeparam>
|
||||
/// <typeparam name="T1"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid<T0, T1>(this ObjectVessel<T0, T1> obj)
|
||||
where T0 : Object
|
||||
where T1 : Object
|
||||
=> obj != null && obj.Target0 != null && obj.Target1 != null;
|
||||
/// <summary>
|
||||
/// 检查容器有效
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <typeparam name="T0"></typeparam>
|
||||
/// <typeparam name="T1"></typeparam>
|
||||
/// <typeparam name="T2"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid<T0, T1, T2>(this ObjectVessel<T0, T1, T2> obj)
|
||||
where T0 : Object
|
||||
where T1 : Object
|
||||
where T2 : Object
|
||||
=> obj != null && obj.Target0 != null && obj.Target1 != null && obj.Target2 != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ee4993e0572478d8c7b5e62baacf30c
|
||||
timeCreated: 1753265877
|
||||
Reference in New Issue
Block a user