S&box Wiki

TypeLibrary

TypeLibrary

TypeLibrary is the replacement for System.Reflection - it'll only let you access types you should have access to within your game.

This example should really show you everything you need to know:

var entName = "BouncyBall"; // Getting a type that matches the name var entityType = TypeLibrary.GetType<Entity>( entName )?.TargetType; if ( entityType == null ) return; // Checking if that type has the SpawnableAttribute on it if ( !TypeLibrary.HasAttribute<SpawnableAttribute>( entityType ) ) return; // Creating an instance of that type var ent = TypeLibrary.Create<Entity>( entityType );