Closed PolSpock closed 9 months ago
Now it's even worse, completely breaking input and spamming the server console
Something has changed since this update, is more stable for me
Same. Network vars seem to be fixed but menu still breaks.
Same. Network vars seem to be fixed but menu still breaks.
Menu breaking on hotload is something I experienced. Here is how I fixed it.
OnAfterTreeRender(true)
is not called when hotloading, something to keep in mind ;@ref
might be null
on reload, you must manually check them ;null
by using "guards".Minimal example with a random component that expects a Player
input :
@using Sandbox;
@using Sandbox.UI;
// guard
@if (Player == null) {
return;
}
<root>
<h1>@(Player.Name)</h1>
<div @ref=ProgressBar></div>
</root>
@code
{
// inputs
public Player Player { get; set; }
// references
private Panel ProgressBar { get; set; }
// properties
private bool IsInitialized => ProgressBar != null;
public override void Tick()
{
if (!IsInitialized) {
return;
}
var progress = 0f; // calculate some progress
ProgressBar.Style.Width = Length.Percent(progress);
}
}
Describe the bug
Hi,
Since the resolution of https://github.com/sboxgame/issues/issues/4066, the hotload for games that used [Net] var was fixed. However, as @MrBrax notices, hotload recently restarting creates errors.
Now it's generally random but I've been able to recreate a scenario for having the error frequently. See below.
To Reproduce
I've been able to bring you an easy way to reproduce : 1) Download & mount
sbox-gunfight
https://github.com/Facepunch/sbox-gunfight/ 2) Start "FFA - Small Town" 3) Hotload the game by editing & saving aGameResource
extended class. Likesbox-gunfight-main\code\WeaponSystem\WeaponDefinition.cs
, just add a function to the class :4) The game starts to be crazy: you cannot play anymore with this spamming console error :
And the HUD of
GameMenu
will be brokenThe sandbox game doesn't have this issue, so i conclude that network replication on hotload is currently broken
Expected behavior
Hotload must not breaking game
Media/Files
No response
Additional context
No response