Skip to content

ScriptableObjects must be instantiated with ScriptableObject.CreateInstance instead of new

Matt Ellis edited this page Mar 26, 2018 · 2 revisions

If the new keyword is used to create a ScriptableObject, the call will fail at run time. This is because a ScriptableObject needs to be created by the Unity engine so that Unity can call the special methods Start, Update, etc.

This inspection will highlight any attempts to new a ScriptableObject derived class, and provides an Alt+Enter quick fix to rewrite the new as a call to ScriptableObject.CreateInstance<T>().

This inspection corresponds to the Unity runtime warning "... must be instantiated using the ScriptableObject.CreateInstance method instead of new ...".

Clone this wiki locally