mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-16 01:18:58 +08:00
feat: replace checkboxes in ObjectToggle with dropdowns
This commit is contained in:
parent
7040e3992b
commit
69a298e5b7
@ -39,14 +39,18 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#f-active {
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
#f-object {
|
#f-object {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#f-active {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#f-active-dropdown {
|
||||||
|
width: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
.drop-area--drag-active > ListView ScrollView {
|
.drop-area--drag-active > ListView ScrollView {
|
||||||
background-color: rgba(0, 255, 255, 0.1);
|
background-color: rgba(0, 255, 255, 0.1);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ namespace nadena.dev.modular_avatar.core.editor.ShapeChanger
|
|||||||
private const string UxmlPath = Root + "ToggledObjectEditor.uxml";
|
private const string UxmlPath = Root + "ToggledObjectEditor.uxml";
|
||||||
private const string UssPath = Root + "ObjectSwitcherStyles.uss";
|
private const string UssPath = Root + "ObjectSwitcherStyles.uss";
|
||||||
|
|
||||||
|
private const string V_On = "ON";
|
||||||
|
private const string V_Off = "OFF";
|
||||||
|
|
||||||
public override VisualElement CreatePropertyGUI(SerializedProperty property)
|
public override VisualElement CreatePropertyGUI(SerializedProperty property)
|
||||||
{
|
{
|
||||||
var uxml = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UxmlPath).CloneTree();
|
var uxml = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UxmlPath).CloneTree();
|
||||||
@ -24,6 +27,21 @@ namespace nadena.dev.modular_avatar.core.editor.ShapeChanger
|
|||||||
uxml.styleSheets.Add(uss);
|
uxml.styleSheets.Add(uss);
|
||||||
uxml.BindProperty(property);
|
uxml.BindProperty(property);
|
||||||
|
|
||||||
|
var f_active = uxml.Q<Toggle>("f-active");
|
||||||
|
var f_active_dropdown = uxml.Q<DropdownField>("f-active-dropdown");
|
||||||
|
|
||||||
|
f_active_dropdown.choices.Add(V_On);
|
||||||
|
f_active_dropdown.choices.Add(V_Off);
|
||||||
|
|
||||||
|
f_active.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
f_active_dropdown.SetValueWithoutNotify(evt.newValue ? V_On : V_Off);
|
||||||
|
});
|
||||||
|
f_active_dropdown.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
f_active.value = evt.newValue == V_On;
|
||||||
|
});
|
||||||
|
|
||||||
return uxml;
|
return uxml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<UXML xmlns:ui="UnityEngine.UIElements" xmlns:ed="UnityEditor.UIElements">
|
<UXML xmlns:ui="UnityEngine.UIElements" xmlns:ed="UnityEditor.UIElements">
|
||||||
<ui:VisualElement class="horizontal">
|
<ui:VisualElement class="horizontal">
|
||||||
<ed:PropertyField name="f-active" binding-path="Active" label=""/>
|
|
||||||
<ed:PropertyField name="f-object" binding-path="Object" label=""/>
|
<ed:PropertyField name="f-object" binding-path="Object" label=""/>
|
||||||
|
<ui:Toggle name="f-active" binding-path="Active" label=""/>
|
||||||
|
<ui:DropdownField name="f-active-dropdown"/>
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</UXML>
|
</UXML>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user