improvements to error reporting

This commit is contained in:
bd_ 2023-03-04 14:41:01 +09:00
parent 76edc43aca
commit e8366cd84a
4 changed files with 42 additions and 6 deletions

View File

@ -247,8 +247,6 @@ namespace nadena.dev.modular_avatar.core.editor
ClonedMenuMappings.Clear();
ErrorReportUI.MaybeOpenErrorReportUI();
AssetDatabase.SaveAssets();
Resources.UnloadUnusedAssets();
@ -259,6 +257,10 @@ namespace nadena.dev.modular_avatar.core.editor
BuildReport.LogException(e);
throw;
}
finally
{
ErrorReportUI.MaybeOpenErrorReportUI();
}
if (!BuildReport.CurrentReport.CurrentAvatar.successful)
{

View File

@ -116,5 +116,7 @@
"control_group.foldout.menu_items": "Bound menu items",
"menuitem.prop.control_group": "Control Group",
"menuitem.prop.control_group.tooltip": "Only one toggle in a given group can be selected at the same time",
"menuitem.prop.is_default": "Is Group Default"
"menuitem.prop.is_default": "Is Group Default",
"animation_gen.duplicate_binding": "Controls from different control groups are trying to animate the same parameter. Parameter: {0}",
"animation_gen.multiple_defaults": "Multiple default menu items were found in the same control group."
}

View File

@ -113,5 +113,7 @@
"control_group.foldout.menu_items": "関連付けされたメニューアイテム",
"menuitem.prop.control_group": "コントロールグループ",
"menuitem.prop.control_group.tooltip": "同じグループ内では、一つのトグルしか起動できません",
"menuitem.prop.is_default": "グループの初期設定にする"
"menuitem.prop.is_default": "グループの初期設定にする",
"animation_gen.duplicate_binding": "別々のコントロールグループから、同じパラメーターが操作されています。パラメーター:{0}",
"animation_gen.multiple_defaults": "同じコントロールグループに初期設定に指定されたメニューアイテムが複数あります。"
}

View File

@ -231,6 +231,8 @@ namespace nadena.dev.modular_avatar.core.editor
group.Add(item);
}
Dictionary<MenuCurveBinding, Component> bindings = new Dictionary<MenuCurveBinding, Component>();
int paramIndex = 0;
foreach (var kvp in groupedItems)
{
@ -275,7 +277,7 @@ namespace nadena.dev.modular_avatar.core.editor
List<ChildMotion> children = new List<ChildMotion>();
List<Motion> motions = GenerateMotions(group, out var inactiveMotion);
List<Motion> motions = GenerateMotions(group, bindings, out var inactiveMotion);
if (!hasDefault)
{
@ -350,8 +352,13 @@ namespace nadena.dev.modular_avatar.core.editor
}
}
private List<Motion> GenerateMotions(List<ModularAvatarMenuItem> items, out Motion inactiveMotion)
private List<Motion> GenerateMotions(
List<ModularAvatarMenuItem> items,
Dictionary<MenuCurveBinding, Component> bindings,
out Motion inactiveMotion)
{
Dictionary<MenuCurveBinding, Component> newBindings = new Dictionary<MenuCurveBinding, Component>();
Dictionary<MenuCurveBinding, (Component, AnimationCurve)> inactiveCurves =
new Dictionary<MenuCurveBinding, (Component, AnimationCurve)>();
@ -405,6 +412,29 @@ namespace nadena.dev.modular_avatar.core.editor
var clip = CurvesToMotion(activeCurves);
clip.name = groupName + " (" + item.gameObject.name + ")";
motions.Add(clip);
foreach (var binding in activeCurves)
{
if (!newBindings.ContainsKey(binding.Key))
{
newBindings.Add(binding.Key, binding.Value.Item1);
}
}
}
foreach (var binding in newBindings)
{
if (bindings.ContainsKey(binding.Key))
{
BuildReport.LogFatal("animation_gen.duplicate_binding", new object[]
{
binding.Key
}, binding.Value, bindings[binding.Key]);
}
else
{
bindings.Add(binding.Key, binding.Value);
}
}
return motions;