A small sandboxed component that, when enabled, creates a render-target panel screen on the GameObject using a specific example panel type, a named render target id, a material, and resolution.
using System;
using System.Collections.Generic;
using System.Text;
using Sandbox;
namespace PanelRenderTarget;
public class CreateFromCodeRtPanelComponent : Component, Component.DontExecuteOnServer
{
protected override void OnEnabled()
{
base.OnEnabled();
TargetPanelSystem.Current.CreatePanelScreen<Example>(GameObject, "flatscreen_tv_display", Material.Load("materials/screen.vmat"), new Vector2Int(1280, 720));
}
}