mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-28 13:54:45 -05:00
remove selector
This commit is contained in:
@@ -16,20 +16,6 @@ namespace UniVRM10
|
||||
{
|
||||
const string SaveTitle = "New folder for vrm-1.0 assets...";
|
||||
|
||||
enum Tab
|
||||
{
|
||||
VrmInstance,
|
||||
LookAt,
|
||||
SpringBone,
|
||||
}
|
||||
static Tab s_selected = default;
|
||||
enum SpringBoneTab
|
||||
{
|
||||
Springs,
|
||||
ColliderGroups,
|
||||
}
|
||||
static SpringBoneTab s_sb_selected = default;
|
||||
|
||||
static bool s_foldRuntimeLookAt = false;
|
||||
|
||||
Vrm10Instance m_instance;
|
||||
@@ -43,9 +29,6 @@ namespace UniVRM10
|
||||
SerializedProperty m_lookatTarget;
|
||||
SerializedProperty m_lookatTargetType;
|
||||
|
||||
Vrm10SpringsWindow m_springs;
|
||||
Vrm10ColliderGroupsWindow m_colliderGroups;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
m_instance = (Vrm10Instance)target;
|
||||
@@ -243,52 +226,35 @@ namespace UniVRM10
|
||||
root.Add(s);
|
||||
}
|
||||
|
||||
List<(Tab, VisualElement)> contents = new()
|
||||
// vrm
|
||||
root.Add(new IMGUIContainer(GUIVrmInstance));
|
||||
|
||||
// lookat
|
||||
root.Add(new IMGUIContainer(GUILookAt));
|
||||
|
||||
// springbone
|
||||
var springboneLabel = new Label("SpringBone");
|
||||
springboneLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
|
||||
springboneLabel.style.marginTop = 8;
|
||||
root.Add(springboneLabel);
|
||||
|
||||
var button_springs = new Button { name = "Springs", text = "Springs" };
|
||||
button_springs.clicked += () =>
|
||||
{
|
||||
(Tab.VrmInstance, new IMGUIContainer(GUIVrmInstance)),
|
||||
(Tab.LookAt, new IMGUIContainer(GUILookAt)),
|
||||
(Tab.SpringBone, GUISpringBone()),
|
||||
Vrm10SpringsWindow.Show(m_instance);
|
||||
};
|
||||
var (tabs, body) = CreateUISelector<Tab>("select UI", s_selected, contents, (selected) =>
|
||||
root.Add(button_springs);
|
||||
|
||||
var button_colliderGroups = new Button { name = "ColliderGroups", text = "ColliderGroups" };
|
||||
button_colliderGroups.clicked += () =>
|
||||
{
|
||||
s_selected = selected;
|
||||
});
|
||||
root.Add(tabs);
|
||||
root.Add(body);
|
||||
Vrm10ColliderGroupsWindow.Show(m_instance);
|
||||
};
|
||||
root.Add(button_colliderGroups);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private (VisualElement, VisualElement) CreateUISelector<T>(string label, T init,
|
||||
IEnumerable<(T, VisualElement)> contents, Action<T> onSelected) where T : Enum
|
||||
{
|
||||
var tabs = new EnumField(label, init);
|
||||
|
||||
var root = new VisualElement();
|
||||
foreach (var (tab, content) in contents)
|
||||
{
|
||||
content.style.display = tab.Equals(init)
|
||||
? DisplayStyle.Flex
|
||||
: DisplayStyle.None
|
||||
;
|
||||
root.Add(content);
|
||||
}
|
||||
|
||||
tabs.RegisterValueChangedCallback(e =>
|
||||
{
|
||||
onSelected((T)e.newValue);
|
||||
foreach (var (tab, content) in contents)
|
||||
{
|
||||
content.style.display = tab.Equals(e.newValue)
|
||||
? DisplayStyle.Flex
|
||||
: DisplayStyle.None
|
||||
;
|
||||
}
|
||||
});
|
||||
|
||||
return (tabs, root);
|
||||
}
|
||||
|
||||
void GUIVrmInstance()
|
||||
{
|
||||
if (m_instance.Vrm == null)
|
||||
@@ -411,38 +377,6 @@ namespace UniVRM10
|
||||
}
|
||||
}
|
||||
|
||||
VisualElement GUISpringBone()
|
||||
{
|
||||
var root = new VisualElement();
|
||||
|
||||
var button_springs = new Button { name = "Springs", text = "Springs" };
|
||||
button_springs.clicked += () =>
|
||||
{
|
||||
m_springs = Vrm10SpringsWindow.Show(m_instance);
|
||||
};
|
||||
|
||||
var button_colliderGroups = new Button { name = "ColliderGroups", text = "ColliderGroups" };
|
||||
button_colliderGroups.clicked += () =>
|
||||
{
|
||||
m_colliderGroups = Vrm10ColliderGroupsWindow.Show(m_instance);
|
||||
};
|
||||
|
||||
|
||||
List<(SpringBoneTab, VisualElement)> contents = new()
|
||||
{
|
||||
(SpringBoneTab.Springs, button_springs),
|
||||
(SpringBoneTab.ColliderGroups, button_colliderGroups),
|
||||
};
|
||||
var (tabs, body) = CreateUISelector<SpringBoneTab>("select UI", s_sb_selected, contents, (selected) =>
|
||||
{
|
||||
s_sb_selected = selected;
|
||||
});
|
||||
root.Add(tabs);
|
||||
root.Add(body);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
static IEnumerable<VRM10SpringBoneJoint> MakeJointsRecursive(VRM10SpringBoneJoint parent)
|
||||
{
|
||||
if (parent.transform.childCount > 0)
|
||||
|
||||
Reference in New Issue
Block a user