修复stylefield显示为红色字段的问题。
This commit is contained in:
@@ -24,9 +24,7 @@ namespace XericUIEditor.OverrideUI
|
||||
private SerializedProperty m_ColorProp;
|
||||
|
||||
// 折叠状态
|
||||
private static bool s_ColorFoldout = false;
|
||||
private static bool s_TextureFoldout = false;
|
||||
private static bool s_MaterialFoldout = false;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using UnityEditor;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
using XericLibrary.Runtime.SuperStyleSheet;
|
||||
|
||||
namespace XericUIEditor
|
||||
@@ -20,14 +18,17 @@ namespace XericUIEditor
|
||||
private const float PADDING = 2f;
|
||||
private const float FOLD_BUTTON_WIDTH = 14f;
|
||||
|
||||
private const string PROP_NAMESPACE = "_namespace";
|
||||
private const string PROP_STYLEPATH = "_stylePath";
|
||||
|
||||
/// <summary>折叠状态(按 property path 缓存)</summary>
|
||||
private static readonly System.Collections.Generic.Dictionary<string, bool> s_FoldoutStates
|
||||
= new System.Collections.Generic.Dictionary<string, bool>();
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var nsProp = property.FindPropertyRelative("Namespace");
|
||||
var pathProp = property.FindPropertyRelative("StylePath");
|
||||
var nsProp = property.FindPropertyRelative(PROP_NAMESPACE);
|
||||
var pathProp = property.FindPropertyRelative(PROP_STYLEPATH);
|
||||
if (nsProp == null || pathProp == null)
|
||||
return LINE_HEIGHT + PADDING * 2;
|
||||
|
||||
@@ -61,12 +62,12 @@ namespace XericUIEditor
|
||||
bool expanded = s_FoldoutStates.TryGetValue(key, out bool fold) && fold;
|
||||
|
||||
// 获取子属性
|
||||
SerializedProperty nsProp = property.FindPropertyRelative("Namespace");
|
||||
SerializedProperty pathProp = property.FindPropertyRelative("StylePath");
|
||||
SerializedProperty nsProp = property.FindPropertyRelative(PROP_NAMESPACE);
|
||||
SerializedProperty pathProp = property.FindPropertyRelative(PROP_STYLEPATH);
|
||||
|
||||
if (nsProp == null || pathProp == null)
|
||||
{
|
||||
EditorGUI.LabelField(position, label, "(StyleField 未初始化)");
|
||||
EditorGUI.LabelField(position, label != null ? label.text : "Style Field", " (未初始化)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -224,7 +225,7 @@ namespace XericUIEditor
|
||||
|
||||
private static string GetNamespace(SerializedProperty property)
|
||||
{
|
||||
var nsProp = property.FindPropertyRelative("Namespace");
|
||||
var nsProp = property.FindPropertyRelative(PROP_NAMESPACE);
|
||||
string ns = nsProp?.stringValue;
|
||||
return string.IsNullOrEmpty(ns) ? "default" : ns;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace XericUIEditor.XTable
|
||||
private static string s_EditText = "";
|
||||
private static string s_SizeEditText = ""; // 气泡输入框当前编辑文本
|
||||
private static int s_SizeEditTargetIndex = -1;
|
||||
private static bool s_SizeEditIsColumn;
|
||||
private static string s_LastFocusedControl = "";
|
||||
|
||||
// 拖拽框选状态
|
||||
@@ -120,7 +119,6 @@ namespace XericUIEditor.XTable
|
||||
{
|
||||
if (int.TryParse(newFocus.Substring("XTableColSizeEdit_".Length), out int idx))
|
||||
{
|
||||
s_SizeEditIsColumn = true;
|
||||
s_SizeEditTargetIndex = idx;
|
||||
s_SizeEditText = s_ColWidths != null && idx < s_ColWidths.Length
|
||||
? s_ColWidths[idx].ToString("F0") : "";
|
||||
@@ -130,7 +128,6 @@ namespace XericUIEditor.XTable
|
||||
{
|
||||
if (int.TryParse(newFocus.Substring("XTableRowSizeEdit_".Length), out int idx))
|
||||
{
|
||||
s_SizeEditIsColumn = false;
|
||||
s_SizeEditTargetIndex = idx;
|
||||
s_SizeEditText = s_RowHeights != null && idx < s_RowHeights.Length
|
||||
? s_RowHeights[idx].ToString("F0") : "";
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace XericUI.Core.StyleSheetUI
|
||||
|
||||
#region 序列化字段
|
||||
|
||||
[Header("五态样式路径")]
|
||||
[SerializeField]
|
||||
[Tooltip("正常状态")]
|
||||
private StyleField m_Normal = new StyleField { Namespace = k_DefaultNamespace, StylePath = k_DefaultColorBasePath + "/NormalColor" };
|
||||
@@ -40,7 +39,6 @@ namespace XericUI.Core.StyleSheetUI
|
||||
[Tooltip("禁用状态")]
|
||||
private StyleField m_Disabled = new StyleField { Namespace = k_DefaultNamespace, StylePath = k_DefaultColorBasePath + "/DisabledColor" };
|
||||
|
||||
[Header("过渡")]
|
||||
[SerializeField]
|
||||
[Range(0.001f, 1f)]
|
||||
[Tooltip("渐变持续时间")]
|
||||
|
||||
@@ -184,11 +184,11 @@ namespace XericUI.OverrideUI
|
||||
t.onClick = d.onClick;
|
||||
});
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button", true)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button (Native)", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericButton;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button", false, 100)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button (Native)", false, 100)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericButton, Button,
|
||||
(Graphic targetGraphic, ButtonClickedEvent onClick)>(
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace XericUI.OverrideUI
|
||||
t.sprite = d;
|
||||
});
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image", true)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image (Native)", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericImage;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image", false, 100)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image (Native)", false, 100)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericImage, Image, Sprite>(
|
||||
o =>
|
||||
|
||||
@@ -198,11 +198,11 @@ namespace XericUI.OverrideUI
|
||||
t.navigation = d.navigation;
|
||||
});
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button", true)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button (Style)", true)]
|
||||
private static bool ValidateReplaceStyleToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericStyleButton;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button", false, 100)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button (Style)", false, 100)]
|
||||
private static void ReplaceStyleToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericStyleButton, Button,
|
||||
(Graphic targetGraphic, ButtonClickedEvent onClick, Navigation navigation)>(
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace XericUI.OverrideUI
|
||||
{
|
||||
#region 序列化字段
|
||||
|
||||
[Header("图像样式")]
|
||||
[SerializeField]
|
||||
[Tooltip("颜色样式路径")]
|
||||
private StyleField m_ColorStyle = new StyleField();
|
||||
@@ -176,11 +175,11 @@ namespace XericUI.OverrideUI
|
||||
o => o.sprite,
|
||||
(t, d) => { t.sprite = d; });
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image", true)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image (Style)", true)]
|
||||
private static bool ValidateReplaceStyleImageToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericStyleImage;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image", false, 100)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image (Style)", false, 100)]
|
||||
private static void ReplaceStyleImageToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericStyleImage, Image, Sprite>(
|
||||
o => o.sprite,
|
||||
|
||||
@@ -253,11 +253,11 @@ namespace XericUI.OverrideUI
|
||||
o => (o.graphic, o.group, o.onValueChanged, o.navigation),
|
||||
(t, d) => { t.graphic = d.graphic; t.group = d.group; t.onValueChanged = d.onValueChanged; t.navigation = d.navigation; });
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle", true)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle (Style)", true)]
|
||||
private static bool ValidateReplaceStyleToggleToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericStyleToggle;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle", false, 100)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle (Style)", false, 100)]
|
||||
private static void ReplaceStyleToggleToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericStyleToggle, Toggle,
|
||||
(Graphic graphic, ToggleGroup group, ToggleEvent onValueChanged, Navigation navigation)>(
|
||||
|
||||
@@ -299,11 +299,11 @@ namespace XericUI
|
||||
Debug.Log("请手动替换toggle下的Checkmark Image组件为XericImage,这样Toggle关闭时取消选中的状态会保持为ison状态");
|
||||
}
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle", true)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle (Native)", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericToggle;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle", false, 100)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle (Native)", false, 100)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericToggle, Toggle,
|
||||
(Graphic graphic, ToggleGroup group, ToggleEvent onValueChanged)>(
|
||||
|
||||
@@ -38,11 +38,11 @@ namespace XericUI.OverrideUI
|
||||
o => (o.targetGraphic, o.onClick),
|
||||
(t, d) => { t.targetGraphic = d.targetGraphic; t.onClick = d.onClick; });
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button", true)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button (Attribute)", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericUIrAttributeButton;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button", false, 100)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Button/Replace To/Unity Button (Attribute)", false, 100)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericUIrAttributeButton, Button,
|
||||
(Graphic targetGraphic, Button.ButtonClickedEvent onClick)>(
|
||||
|
||||
@@ -55,11 +55,11 @@ namespace XericUI.OverrideUI
|
||||
o => o.sprite,
|
||||
(t, d) => { t.sprite = d; });
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image", true)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image (Attribute)", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericUIrAttributeText;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image", false, 100)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Image/Replace To/Unity Image (Attribute)", false, 100)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericUIrAttributeText, Image, Sprite>(
|
||||
o => o.sprite,
|
||||
|
||||
@@ -42,11 +42,11 @@ namespace XericUI.OverrideUI
|
||||
t.onValueChanged = d.onValueChanged;
|
||||
});
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle", true)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle (Attribute)", true)]
|
||||
private static bool ValidateReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.context is XericUIrAttributeToggle;
|
||||
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle", false, 100)]
|
||||
[UnityEditor.MenuItem("CONTEXT/Toggle/Replace To/Unity Toggle (Attribute)", false, 100)]
|
||||
private static void ReplaceToUnity(UnityEditor.MenuCommand command)
|
||||
=> command.ReplaceCommandContext<XericUIrAttributeToggle, Toggle,
|
||||
(Graphic graphic, ToggleGroup group, Toggle.ToggleEvent onValueChanged)>(
|
||||
|
||||
@@ -66,7 +66,6 @@ namespace XericUI.XTable.Rendering.Elements
|
||||
RegisterField("/cell/font/size", OnStyleChanged);
|
||||
RegisterField("/cell/font/alignment", OnStyleChanged);
|
||||
RegisterField("/cell/font/richText", OnStyleChanged);
|
||||
RegisterField("/cell/font/fontAsset", OnStyleChanged);
|
||||
|
||||
m_IsBound = true;
|
||||
RefreshAll();
|
||||
@@ -123,20 +122,6 @@ namespace XericUI.XTable.Rendering.Elements
|
||||
StyleValue richVal = GetStyleValue("/cell/font/richText");
|
||||
if (richVal != null && TextComponent != null)
|
||||
TextComponent.richText = (bool)richVal;
|
||||
|
||||
// 字体资源
|
||||
StyleValue fontVal = GetStyleValue("/cell/font/fontAsset");
|
||||
if (fontVal != null && TextComponent != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
TextComponent.font = fontVal.GetValueAs<TMP_FontAsset>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
/* 类型不匹配时忽略 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -47,3 +47,21 @@ cell/default/ {
|
||||
height = 40:System.Single @Desc:默认行高
|
||||
width = 100:System.Single @Desc:默认列宽
|
||||
}
|
||||
|
||||
|
||||
/button/TargetGraphic/ColorTint:UnityEngine.UI.ColorBlock/ {
|
||||
.NormalColor = (1,1,1,1)
|
||||
.HighlightedColor = (0.96,0.96,0.96,1)
|
||||
.PressedColor = (0.78,0.78,0.78,1)
|
||||
.SelectedColor = (0.96,0.96,0.96,1)
|
||||
.DisabledColor = (0.6,0.6,0.6,0.8)
|
||||
}
|
||||
|
||||
/toggle/TargetGraphic/ColorTint:UnityEngine.UI.ColorBlock/ {
|
||||
.NormalColor = (1,1,1,1)
|
||||
.HighlightedColor = (0.96,0.96,0.96,1)
|
||||
.PressedColor = (0.78,0.78,0.78,1)
|
||||
.SelectedColor = (0.96,0.96,0.96,1)
|
||||
.DisabledColor = (0.6,0.6,0.6,0.8)
|
||||
.DisabledColor = (0.6,0.6,0.6,0.8)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user