Disable "Performing a potentially slow search for component..."


With the update to 5.0 adding a component on the fly produces the following warning:
“Performing potentially slow search for component [Component Name]”

This happens after using what used to be “gameObject.AddComponent([Component Name as string]);”

I really need to know how to disable this warning, or an alternative to this. My main goal is to add components based on a provided string as their name.


Don’t use the String type of AddComponent.


From the docs :

AddComponent(string), when called with a variable cannot be automatically updated to the generic version

 AddComponent<T>() //<-(C#)   [AddComponent.<T>() (uJS)]

In such cases the API Updater will replace the call with a call to APIUpdaterRuntimeServices.AddComponent(). This method is meant to allow you to test your game in editor mode (they do a best effort to try to resolve the type at runtime) but it is not meant to be used in production, so it is an error to build a game with calls to such method). On platforms that support Type.GetType(string) you can try to use GetComponent(Type.GetType(typeName)) as a workaround.