Editor/UpgradedShaderGraph/Core/MissingNode.cs

An editor UI node type representing a missing or unknown shader graph node. Stores a title and the serialized JSON content, measures text size for layout, and draws the content and a warning icon in the editor.

File Access
namespace Editor.ShaderGraphExtras;

public class MissingNode : BaseNode
{
	[Hide]
	public string Title { get; set; }

	[Hide]
	private string _content = "";

	[Hide]
	public string Content
	{
		get => _content;
		set
		{
			_content = value;
			Paint.SetDefaultFont();
			ContentSize = Paint.MeasureText( Content );
			ExpandSize = new Vector2( 30, ContentSize.y + 16 );
		}
	}

	[Hide]
	Vector2 ContentSize = new();

	[Hide]
	public override Color PrimaryColor => Theme.MultipleValues;

	public MissingNode()
	{
	}

	public MissingNode( string title, JsonElement json ) : base()
	{
		Title = title;
		Content = json.ToString();
	}

	public override void OnPaint( Rect rect )
	{
		Paint.SetDefaultFont();
		Paint.DrawText( rect.Shrink( 8, 22, 8, 8 ), Content, TextFlag.LeftTop );
	}

	[JsonIgnore, Hide, Browsable( false )]
	public override DisplayInfo DisplayInfo
	{
		get
		{
			var info = base.DisplayInfo;
			info.Name = "Missing " + Title ?? info.Name;
			info.Icon = "error";
			return info;
		}
	}
}