Debug/CreateFromCodeComponent.cs

A small s&box component that, when enabled, creates a render-target panel attached to its GameObject using TargetPanelSystem.Current.CreatePanelScreen with an Example UI type, a named panel id, a material, and a resolution.

Native Interop
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));
	}
}