完善反射菜单
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XericUI.Helper;
|
||||
using XericUI.ReflectionUIGenerator;
|
||||
|
||||
namespace XericUI.OverrideUI
|
||||
{
|
||||
/// <summary>
|
||||
/// 带字段标记的增强按钮组件
|
||||
/// 继承 XericButton,额外支持 XuiavrgFieldTag 标记,便于反射界面生成器自动绑定
|
||||
/// </summary>
|
||||
[AddComponentMenu("Xeric UI Vessel/Attribute/Button", 51)]
|
||||
public class XericUIrAttributeButton : XericButton, IXuiavrgFieldTagProvider
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("Entry 功能标记,用于自动绑定匹配")]
|
||||
private XuiavrgFieldTag _entryTag = XuiavrgFieldTag.Button;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("同一 Tag 存在多个时的索引区分")]
|
||||
private int _tagIndex = 0;
|
||||
|
||||
public XuiavrgFieldTag EntryTag => _entryTag;
|
||||
public int TagIndex => _tagIndex;
|
||||
|
||||
#region 组件替换
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To XericUIrAttributeButton", true)]
|
||||
private static bool ValidateReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.context is Button and not XericUIrAttributeButton;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To XericUIrAttributeButton", false, 11)]
|
||||
private static void ReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<Button, XericUIrAttributeButton,
|
||||
(Graphic targetGraphic, Button.ButtonClickedEvent onClick)>(
|
||||
o => (o.targetGraphic, o.onClick),
|
||||
(t, d) => { t.targetGraphic = d.targetGraphic; t.onClick = d.onClick; });
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To Button", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericUIrAttributeButton;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To Button", false, 11)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericUIrAttributeButton, Button,
|
||||
(Graphic targetGraphic, Button.ButtonClickedEvent onClick)>(
|
||||
o => (o.targetGraphic, o.onClick),
|
||||
(t, d) => { t.targetGraphic = d.targetGraphic; t.onClick = d.onClick; });
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f39882be385237b4791af43ba89fec27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XericUI.Helper;
|
||||
using XericUI.ReflectionUIGenerator;
|
||||
|
||||
namespace XericUI.OverrideUI
|
||||
{
|
||||
/// <summary>
|
||||
/// 带字段标记的增强下拉框组件
|
||||
/// 继承 Unity Dropdown,额外支持 XuiavrgFieldTag 标记,便于反射界面生成器自动绑定
|
||||
/// </summary>
|
||||
[AddComponentMenu("Xeric UI Vessel/Attribute/Dropdown", 51)]
|
||||
public class XericUIrAttributeDropdown : Dropdown, IXuiavrgFieldTagProvider
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("Entry 功能标记,用于自动绑定匹配")]
|
||||
private XuiavrgFieldTag _entryTag = XuiavrgFieldTag.Dropdown;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("同一 Tag 存在多个时的索引区分")]
|
||||
private int _tagIndex = 0;
|
||||
|
||||
public XuiavrgFieldTag EntryTag => _entryTag;
|
||||
public int TagIndex => _tagIndex;
|
||||
|
||||
#region 组件替换
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.MenuItem("CONTEXT/Dropdown/Replace To XericUIrAttributeDropdown", true)]
|
||||
private static bool ValidateReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.context is Dropdown and not XericUIrAttributeDropdown;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Dropdown/Replace To XericUIrAttributeDropdown", false, 10)]
|
||||
private static void ReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<Dropdown, XericUIrAttributeDropdown,
|
||||
(Graphic targetGraphic, int value, List<OptionData> options, DropdownEvent onValueChanged)>(
|
||||
o =>
|
||||
(o.targetGraphic, o.value, o.options, o.onValueChanged),
|
||||
(t, d) =>
|
||||
{
|
||||
t.targetGraphic = d.targetGraphic;
|
||||
t.value = d.value;
|
||||
t.options = d.options;
|
||||
t.onValueChanged = d.onValueChanged;
|
||||
});
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Dropdown/Replace To Dropdown", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericUIrAttributeDropdown;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Dropdown/Replace To Dropdown", false, 10)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericUIrAttributeDropdown, Dropdown,
|
||||
(Graphic targetGraphic, int value, List<OptionData> options, DropdownEvent onValueChanged)>(
|
||||
o =>
|
||||
(o.targetGraphic, o.value, o.options, o.onValueChanged),
|
||||
(t, d) =>
|
||||
{
|
||||
t.targetGraphic = d.targetGraphic;
|
||||
t.value = d.value;
|
||||
t.options = d.options;
|
||||
t.onValueChanged = d.onValueChanged;
|
||||
});
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f84f2204fb53b04fbf647213e92b0f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XericUI.Helper;
|
||||
using XericUI.ReflectionUIGenerator;
|
||||
|
||||
namespace XericUI.OverrideUI
|
||||
{
|
||||
/// <summary>
|
||||
/// 带字段标记的增强输入框组件
|
||||
/// 继承 Unity InputField,额外支持 XuiavrgFieldTag 标记,便于反射界面生成器自动绑定
|
||||
/// </summary>
|
||||
[AddComponentMenu("Xeric UI Vessel/Attribute/InputField", 51)]
|
||||
public class XericUIrAttributeInputField : InputField, IXuiavrgFieldTagProvider
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("Entry 功能标记,用于自动绑定匹配")]
|
||||
private XuiavrgFieldTag _entryTag = XuiavrgFieldTag.Input;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("同一 Tag 存在多个时的索引区分")]
|
||||
private int _tagIndex = 0;
|
||||
|
||||
public XuiavrgFieldTag EntryTag => _entryTag;
|
||||
public int TagIndex => _tagIndex;
|
||||
|
||||
#region 组件替换
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.MenuItem("CONTEXT/InputField/Replace To XericUIrAttributeInputField", true)]
|
||||
private static bool ValidateReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.context is InputField and not XericUIrAttributeInputField;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/InputField/Replace To XericUIrAttributeInputField", false, 10)]
|
||||
private static void ReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<InputField, XericUIrAttributeInputField,
|
||||
(Graphic targetGraphic, string text, InputField.OnChangeEvent onValueChanged, InputField.EndEditEvent onEndEdit)>(
|
||||
o => (o.targetGraphic, o.text, o.onValueChanged, o.onEndEdit),
|
||||
(t, d) =>
|
||||
{
|
||||
t.targetGraphic = d.targetGraphic;
|
||||
t.text = d.text;
|
||||
t.onValueChanged = d.onValueChanged;
|
||||
t.onEndEdit = d.onEndEdit;
|
||||
});
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/InputField/Replace To InputField", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericUIrAttributeInputField;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/InputField/Replace To InputField", false, 10)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericUIrAttributeInputField, InputField,
|
||||
(Graphic targetGraphic, string text, InputField.OnChangeEvent onValueChanged, InputField.EndEditEvent onEndEdit)>(
|
||||
o => (o.targetGraphic, o.text, o.onValueChanged, o.onEndEdit),
|
||||
(t, d) =>
|
||||
{
|
||||
t.targetGraphic = d.targetGraphic;
|
||||
t.text = d.text;
|
||||
t.onValueChanged = d.onValueChanged;
|
||||
t.onEndEdit = d.onEndEdit;
|
||||
});
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd5f00c3fa1461a4e8b222779a796cc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XericUI.Helper;
|
||||
using XericUI.ReflectionUIGenerator;
|
||||
|
||||
namespace XericUI.OverrideUI
|
||||
{
|
||||
/// <summary>
|
||||
/// 带字段标记的增强滑块组件
|
||||
/// 继承 Unity Slider,额外支持 XuiavrgFieldTag 标记,便于反射界面生成器自动绑定
|
||||
/// </summary>
|
||||
[AddComponentMenu("Xeric UI Vessel/Attribute/Slider", 51)]
|
||||
public class XericUIrAttributeSlider : Slider, IXuiavrgFieldTagProvider
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("Entry 功能标记,用于自动绑定匹配")]
|
||||
private XuiavrgFieldTag _entryTag = XuiavrgFieldTag.Slider;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("同一 Tag 存在多个时的索引区分")]
|
||||
private int _tagIndex = 0;
|
||||
|
||||
public XuiavrgFieldTag EntryTag => _entryTag;
|
||||
public int TagIndex => _tagIndex;
|
||||
|
||||
#region 组件替换
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.MenuItem("CONTEXT/Slider/Replace To XericUIrAttributeSlider", true)]
|
||||
private static bool ValidateReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.context is Slider and not XericUIrAttributeSlider;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Slider/Replace To XericUIrAttributeSlider", false, 10)]
|
||||
private static void ReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<Slider, XericUIrAttributeSlider,
|
||||
(Graphic targetGraphic, float value, Slider.SliderEvent onValueChanged)>(
|
||||
o =>
|
||||
(o.targetGraphic, o.value, o.onValueChanged),
|
||||
(t, d) =>
|
||||
{
|
||||
t.targetGraphic = d.targetGraphic;
|
||||
t.value = d.value;
|
||||
t.onValueChanged = d.onValueChanged;
|
||||
});
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Slider/Replace To Slider", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericUIrAttributeSlider;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Slider/Replace To Slider", false, 10)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericUIrAttributeSlider, Slider,
|
||||
(Graphic targetGraphic, float value, Slider.SliderEvent onValueChanged)>(
|
||||
o =>
|
||||
(o.targetGraphic, o.value, o.onValueChanged),
|
||||
(t, d) =>
|
||||
{
|
||||
t.targetGraphic = d.targetGraphic;
|
||||
t.value = d.value;
|
||||
t.onValueChanged = d.onValueChanged;
|
||||
});
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 263e829bad1c50d469036934e671aaa8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XericUI.Helper;
|
||||
using XericUI.ReflectionUIGenerator;
|
||||
|
||||
namespace XericUI.OverrideUI
|
||||
{
|
||||
/// <summary>
|
||||
/// 带字段标记的增强文本组件
|
||||
/// 继承 XericImage,额外支持 XuiavrgFieldTag 标记。
|
||||
/// 主要用于预制体中标记 Label/Output/Sign 等文本功能元素
|
||||
/// </summary>
|
||||
[AddComponentMenu("Xeric UI Vessel/Attribute/Text", 51)]
|
||||
public class XericUIrAttributeText : XericImage, IXuiavrgFieldTagProvider
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("关联的 Text 组件引用(可选,用于读取/写入文本内容)")]
|
||||
private Text _targetText;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Entry 功能标记,用于自动绑定匹配")]
|
||||
private XuiavrgFieldTag _entryTag = XuiavrgFieldTag.Label;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("同一 Tag 存在多个时的索引区分")]
|
||||
private int _tagIndex = 0;
|
||||
|
||||
public XuiavrgFieldTag EntryTag => _entryTag;
|
||||
public int TagIndex => _tagIndex;
|
||||
|
||||
/// <summary>文本内容(通过 _targetText 读写)</summary>
|
||||
public string TextContent
|
||||
{
|
||||
get => _targetText != null ? _targetText.text : string.Empty;
|
||||
set { if (_targetText) _targetText.text = value; }
|
||||
}
|
||||
|
||||
/// <summary>文本颜色</summary>
|
||||
public Color TextColor
|
||||
{
|
||||
get => _targetText != null ? _targetText.color : Color.white;
|
||||
set { if (_targetText) _targetText.color = value; }
|
||||
}
|
||||
|
||||
#region 组件替换
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To XericUIrAttributeText", true)]
|
||||
private static bool ValidateReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.context is Image and not XericUIrAttributeText;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To XericUIrAttributeText", false, 11)]
|
||||
private static void ReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<Image, XericUIrAttributeText, Sprite>(
|
||||
o => o.sprite,
|
||||
(t, d) => { t.sprite = d; });
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To Image", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericUIrAttributeText;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To Image", false, 11)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericUIrAttributeText, Image, Sprite>(
|
||||
o => o.sprite,
|
||||
(t, d) => { t.sprite = d; });
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5189154ac8f148f449041fd8890c9730
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XericUI.Helper;
|
||||
using XericUI.ReflectionUIGenerator;
|
||||
|
||||
namespace XericUI.OverrideUI
|
||||
{
|
||||
/// <summary>
|
||||
/// 带字段标记的增强开关组件
|
||||
/// 继承 XericToggle,额外支持 XuiavrgFieldTag 标记,便于反射界面生成器自动绑定
|
||||
/// </summary>
|
||||
[AddComponentMenu("Xeric UI Vessel/Attribute/Toggle", 32)]
|
||||
public class XericUIrAttributeToggle : XericToggle, IXuiavrgFieldTagProvider
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("Entry 功能标记,用于自动绑定匹配")]
|
||||
private XuiavrgFieldTag _entryTag = XuiavrgFieldTag.Toggle;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("同一 Tag 存在多个时的索引区分")]
|
||||
private int _tagIndex = 0;
|
||||
|
||||
public XuiavrgFieldTag EntryTag => _entryTag;
|
||||
public int TagIndex => _tagIndex;
|
||||
|
||||
#region 组件替换
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To XericUIrAttributeToggle", true)]
|
||||
private static bool ValidateReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.context is Toggle and not XericUIrAttributeToggle;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To XericUIrAttributeToggle", false, 11)]
|
||||
private static void ReplaceToAttribute(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<Toggle, XericUIrAttributeToggle,
|
||||
(Graphic graphic, ToggleGroup group, Toggle.ToggleEvent onValueChanged)>(
|
||||
o => (o.graphic, o.group, o.onValueChanged),
|
||||
(t, d) =>
|
||||
{
|
||||
t.graphic = d.graphic;
|
||||
t.group = d.group;
|
||||
t.onValueChanged = d.onValueChanged;
|
||||
});
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To Toggle", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericUIrAttributeToggle;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To Toggle", false, 11)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericUIrAttributeToggle, Toggle,
|
||||
(Graphic graphic, ToggleGroup group, Toggle.ToggleEvent onValueChanged)>(
|
||||
o => (o.graphic, o.group, o.onValueChanged),
|
||||
(t, d) =>
|
||||
{
|
||||
t.graphic = d.graphic;
|
||||
t.group = d.group;
|
||||
t.onValueChanged = d.onValueChanged;
|
||||
});
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c20b871bced43a34a89dd5a7cf05c90b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user