An extension method on GameObjectDirectory that returns the first GameObject whose Name exactly matches a given string. It iterates results from FindByName and compares the Name property, returning the matching object or null.
using Sandbox;
public static class Directory_Extensions
{
public static GameObject FindbyName(this GameObjectDirectory d, string n)
{
foreach (var go in d.FindByName(n))
{
if (go.Name == n)
return go;
}
return null;
}
}