修复stylefield展开的尺寸计算错误问题
This commit is contained in:
@@ -30,13 +30,13 @@ namespace XericUIEditor
|
|||||||
var nsProp = property.FindPropertyRelative(PROP_NAMESPACE);
|
var nsProp = property.FindPropertyRelative(PROP_NAMESPACE);
|
||||||
var pathProp = property.FindPropertyRelative(PROP_STYLEPATH);
|
var pathProp = property.FindPropertyRelative(PROP_STYLEPATH);
|
||||||
if (nsProp == null || pathProp == null)
|
if (nsProp == null || pathProp == null)
|
||||||
return LINE_HEIGHT + PADDING * 2;
|
return PADDING + (LINE_HEIGHT + PADDING);
|
||||||
|
|
||||||
string key = GetFoldKey(property);
|
string key = GetFoldKey(property);
|
||||||
bool expanded = s_FoldoutStates.TryGetValue(key, out bool f) && f;
|
bool expanded = s_FoldoutStates.TryGetValue(key, out bool f) && f;
|
||||||
|
|
||||||
if (!expanded)
|
if (!expanded)
|
||||||
return LINE_HEIGHT + PADDING * 2;
|
return PADDING + (LINE_HEIGHT + PADDING);
|
||||||
|
|
||||||
// 基础:命名空间 + 路径 = 2 行
|
// 基础:命名空间 + 路径 = 2 行
|
||||||
int rowCount = 2;
|
int rowCount = 2;
|
||||||
@@ -53,7 +53,7 @@ namespace XericUIEditor
|
|||||||
if (annotations != null && annotations.Count > 0)
|
if (annotations != null && annotations.Count > 0)
|
||||||
rowCount++;
|
rowCount++;
|
||||||
|
|
||||||
return (LINE_HEIGHT + PADDING) * rowCount + PADDING;
|
return PADDING + (1 + rowCount) * (LINE_HEIGHT + PADDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||||
@@ -94,6 +94,9 @@ namespace XericUIEditor
|
|||||||
|
|
||||||
string currentNs = GetNamespace(property);
|
string currentNs = GetNamespace(property);
|
||||||
|
|
||||||
|
// 首次绘制时 xsss 可能尚未加载,当前命名空间若无效则自动切换
|
||||||
|
EnsureValidNamespace(nsProp, ref currentNs);
|
||||||
|
|
||||||
DrawPathDropdown(pathRect, pathProp, currentNs);
|
DrawPathDropdown(pathRect, pathProp, currentNs);
|
||||||
|
|
||||||
if (!expanded)
|
if (!expanded)
|
||||||
@@ -243,6 +246,30 @@ namespace XericUIEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 若当前命名空间无可用路径(xsss 尚未加载),自动切换至首个有路径的命名空间。
|
||||||
|
/// </summary>
|
||||||
|
private static void EnsureValidNamespace(SerializedProperty nsProp, ref string currentNs)
|
||||||
|
{
|
||||||
|
var paths = StyleManager.GetPathsForNamespace(currentNs);
|
||||||
|
if (paths.Count > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 当前命名空间不可用,尝试其他命名空间
|
||||||
|
var allNs = StyleManager.GetAvailableNamespaces();
|
||||||
|
foreach (var ns in allNs)
|
||||||
|
{
|
||||||
|
if (ns == currentNs) continue;
|
||||||
|
var altPaths = StyleManager.GetPathsForNamespace(ns);
|
||||||
|
if (altPaths.Count > 0)
|
||||||
|
{
|
||||||
|
currentNs = ns;
|
||||||
|
nsProp.stringValue = ns;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user