@using MenuProject.MenuUI.Toasts @using Sandbox; @using Sandbox.UI; @namespace Menu @inherits Panel @code { public static Toasts Instance { get; private set; } protected override void OnAfterTreeRender ( bool firstTime ) { base.OnAfterTreeRender( firstTime ); if ( firstTime ) { Instance = this; } } public void AddToast ( string message, Action action, float duration = 10f ) { var entry = new ToastEntry(); entry.Text = message; entry.Duration = duration * Scene.TimeScale; entry.Action = action; AddChild( entry ); } public void AddToast(string message, string image, Action action, float duration = 10f) { var entry = new ToastEntry(); entry.Text = message; entry.Duration = duration * Scene.TimeScale; entry.Image = image; entry.Action = action; AddChild(entry); } }