mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-19 21:00:08 +08:00
fix: modular avatar parameters is super slow (#834)
This commit is contained in:
parent
3ebc4fb2cf
commit
c111b29fbb
@ -36,23 +36,19 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
#if UNITY_2022_1_OR_NEWER
|
||||||
|
private bool _delayPending = false;
|
||||||
|
|
||||||
|
private void DelayRecalculate()
|
||||||
{
|
{
|
||||||
#if UNITY_2022_1_OR_NEWER
|
_delayPending = false;
|
||||||
ObjectChangeEvents.changesPublished += OnChangesPublished;
|
|
||||||
#endif
|
|
||||||
Recalculate();
|
Recalculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_2022_1_OR_NEWER
|
|
||||||
private void OnChangesPublished(ref ObjectChangeEventStream stream)
|
private void OnChangesPublished(ref ObjectChangeEventStream stream)
|
||||||
{
|
{
|
||||||
Recalculate();
|
if (!_delayPending) EditorApplication.delayCall += DelayRecalculate;
|
||||||
}
|
_delayPending = true;
|
||||||
|
|
||||||
private void OnDisable()
|
|
||||||
{
|
|
||||||
ObjectChangeEvents.changesPublished -= OnChangesPublished;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -65,7 +61,18 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
_legendContainer = _root.Q<VisualElement>("Legend");
|
_legendContainer = _root.Q<VisualElement>("Legend");
|
||||||
_usageBoxContainer = _root.Q<VisualElement>("UsageBox");
|
_usageBoxContainer = _root.Q<VisualElement>("UsageBox");
|
||||||
|
|
||||||
Recalculate();
|
#if UNITY_2022_1_OR_NEWER
|
||||||
|
_root.RegisterCallback<AttachToPanelEvent>(_evt =>
|
||||||
|
{
|
||||||
|
ObjectChangeEvents.changesPublished += OnChangesPublished;
|
||||||
|
Recalculate();
|
||||||
|
});
|
||||||
|
|
||||||
|
_root.RegisterCallback<DetachFromPanelEvent>(_evt =>
|
||||||
|
{
|
||||||
|
ObjectChangeEvents.changesPublished -= OnChangesPublished;
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
return _root;
|
return _root;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user