- Add a link/unlink icon to the right of the name field.
- Only show the rich text preview when there is the character '<' in the label field.
- Toggling link from ON to OFF will set the label to the current GameObject name.
This commit is contained in:
Haï~ 2024-09-03 22:25:20 +02:00
parent b01b280f79
commit 776f08be3f
2 changed files with 21 additions and 17 deletions

View File

@ -260,6 +260,8 @@ namespace nadena.dev.modular_avatar.core.editor
EditorGUILayout.BeginHorizontal();
EditorGUILayout.BeginVertical();
EditorGUILayout.BeginHorizontal();
var needsRichLabel = (!string.IsNullOrEmpty(_prop_label.stringValue) || _isTryingRichLabel);
if (!needsRichLabel)
{
@ -274,8 +276,24 @@ namespace nadena.dev.modular_avatar.core.editor
{
EditorGUILayout.PropertyField(_prop_label, G("menuitem.prop.name"));
}
var linkIcon = EditorGUIUtility.IconContent(needsRichLabel ? "UnLinked" : "Linked").image;
var guiIcon = new GUIContent(linkIcon, S(needsRichLabel ? "menuitem.rich_text.toggle_off.tooltip" : "menuitem.rich_text.toggle_on.tooltip"));
if (GUILayout.Button(guiIcon, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.Width(25)))
{
if (!needsRichLabel)
{
_isTryingRichLabel = true;
_prop_label.stringValue = _name.stringValue;
}
else
{
_isTryingRichLabel = false;
_prop_label.stringValue = "";
}
}
EditorGUILayout.EndHorizontal();
if (needsRichLabel)
if (needsRichLabel && _prop_label.stringValue.Contains("<"))
{
var style = new GUIStyle(EditorStyles.textField);
style.richText = true;
@ -292,20 +310,6 @@ namespace nadena.dev.modular_avatar.core.editor
ShowInnateParameterGUI();
var newRichValue = EditorGUILayout.Toggle(G("menuitem.prop.rich_text"), needsRichLabel);
if (newRichValue != needsRichLabel)
{
if (newRichValue)
{
_isTryingRichLabel = true;
}
else
{
_isTryingRichLabel = false;
_prop_label.stringValue = "";
}
}
EditorGUILayout.EndVertical();
if (_texture != null)

View File

@ -282,6 +282,6 @@
"ro_sim.effect_group.rule_inverted.tooltip": "This rule will be applied when one of its conditions is NOT met",
"ro_sim.effect_group.conditions": "Conditions",
"menuitem.prop.rich_text": "Rich text",
"menuitem.prop.rich_text.tooltip": "Use a long name which may contain rich text and line breaks."
"menuitem.rich_text.toggle_on.tooltip": "Use a long name which may contain rich text and line breaks.",
"menuitem.rich_text.toggle_off.tooltip": "Use the GameObject name."
}