Revision Difference
TypeLibrary#561156
<cat>Code.Misc</cat>
<title>TypeLibrary</title>
<deprecated>Code example is outdated</deprecated>⤶
<warning>Code example is outdated</warning>⤶
# 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:
```csharp
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 );
```