JetBrains Rider 2025.3 Help

Code inspection: Expected a type derived from 'ScriptableObject'

This inspection ensures type safety for Unity's string-based ScriptableObject creation API, specifically targeting the ScriptableObject.CreateInstance(string) method.

How it works

The inspection uses Unity-specific reference providers to resolve the string literal to a type declaration within the project or libraries. Once the type is resolved, the analyzer checks its inheritance hierarchy.

Validation rule: The resolved type must derive from UnityEngine.ScriptableObject.

If the resolved type exists but does not inherit from ScriptableObject, the inspection produces a warning. This prevents runtime errors where Unity would fail to instantiate the object because the specified type is not a valid ScriptableObject.

Example

In this example, MyPlainClass does not inherit from ScriptableObject, so it cannot be instantiated using CreateInstance.

public class MyPlainClass { } public class MyScript : MonoBehaviour { void Start() { // Reported: MyPlainClass is not a ScriptableObject ScriptableObject.CreateInstance("MyPlainClass"); } }
public class MyData : ScriptableObject { } public class MyScript : MonoBehaviour { void Start() { // After fix: MyData is a ScriptableObject ScriptableObject.CreateInstance("MyData"); } }
26 March 2026