fix: select menu creates menu install targets in random order (#530)

Fixes: #508
This commit is contained in:
bd_ 2023-11-14 20:42:01 +09:00 committed by GitHub
parent f04171ddb4
commit 1410503609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,7 +264,7 @@ namespace nadena.dev.modular_avatar.core.editor
{
installTo.objectReferenceValue = null;
foreach (var target in targets)
foreach (var target in targets.Cast<Component>().OrderBy(ObjectHierarchyOrder))
{
var installer = (ModularAvatarMenuInstaller) target;
var child = new GameObject();
@ -371,6 +371,20 @@ namespace nadena.dev.modular_avatar.core.editor
Localization.ShowLanguageUI();
}
private string ObjectHierarchyOrder(Component arg)
{
var list = new List<int>();
var t = arg.transform;
while (t != null)
{
list.Add(t.GetSiblingIndex());
t = t.parent;
}
list.Reverse();
return string.Join("", list.Select(n => (char) n));
}
private void ExtractMenu()
{
serializedObject.ApplyModifiedProperties();