public static void UpdateLabel() { if (Labels.Count > 0) { if (!Node.IsInstanceValid(instance)) { var layer = new CanvasLayer(); layer.AddChild(instance = new DrawDebugLabels()); layer.AddChild(vScroll = new VScrollBar()); Scene.Current.AddChild(layer); layer.Owner = Scene.Current; instance.Owner = layer; vScroll.Owner = layer; } if (Labels.Count < lastcount) // fixes text bug when less text is printed than last frame { var layer = instance.GetParent(); layer.RemoveChild(instance); layer.AddChild(instance); } builder.Clear(); vScroll.MaxValue = (Labels.Count - 1).min(1); int scroll = (int)vScroll.Value; int count = 0; while (count < 50) { var current = scroll + count; if (current >= Labels.Count) { break; } builder.Append(Labels[current]); count++; } instance.Text = builder.ToString(); lastcount = Labels.Count; Labels.Clear(); } else if (Node.IsInstanceValid(instance)) { instance.GetParent().QueueFree(); } }
public void OnDispatch(Debug args) { DrawDebugLabels.UpdateLabel(); DrawDebugLine2D.UpdateDrawLine2D(); DrawDebugLine3D.UpdateDrawLine3D(); }