diff --git a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs index 0a5365e652eb..0bdbce13d383 100644 --- a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs @@ -81,7 +81,25 @@ public float Y private HitObjectProperty stackHeight; - public Bindable StackHeightBindable => stackHeight.Bindable; + public Bindable StackHeightBindable + { + get + { + if (stackHeight.BindableCreated) + return stackHeight.Bindable; + + stackHeight.Bindable.BindValueChanged(height => + { + foreach (var nested in NestedHitObjects) + { + if (nested is OsuHitObject osuHitObject) + osuHitObject.StackHeight = height.NewValue; + } + }); + + return stackHeight.Bindable; + } + } public int StackHeight { @@ -155,18 +173,6 @@ public bool LastInCombo set => lastInCombo.Value = value; } - protected OsuHitObject() - { - StackHeightBindable.BindValueChanged(height => - { - foreach (var nested in NestedHitObjects) - { - if (nested is OsuHitObject osuHitObject) - osuHitObject.StackHeight = height.NewValue; - } - }); - } - protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty) { base.ApplyDefaultsToSelf(controlPointInfo, difficulty); diff --git a/osu.Game/Rulesets/Objects/HitObjectProperty.cs b/osu.Game/Rulesets/Objects/HitObjectProperty.cs index f1df83f80c76..d3103e6d6e96 100644 --- a/osu.Game/Rulesets/Objects/HitObjectProperty.cs +++ b/osu.Game/Rulesets/Objects/HitObjectProperty.cs @@ -26,6 +26,11 @@ public struct HitObjectProperty /// public Bindable Bindable => backingBindable ??= new Bindable(defaultValue) { Value = backingValue }; + /// + /// Whether the backing bindable has already been created. + /// + public bool BindableCreated => backingBindable != null; + /// /// The current value, derived from and delegated to if initialised, or a temporary field otherwise. ///