Are there way of count some classes inside ScriptableObject?

In this scriptableobject, “WeaponValues”,

are there way of how to know the number of specific weapongeneral inherited classes(ShortSword, BroadSword, etc)?

so for above case, 6 should be returned.

Are you interested in how many fields of that type this class has, or are you interested in how many different types exist in your project?

This answer is for how many exist in your project: You can do this with reflection. Assuming your base class is called “WeaponGeneral” it would be something like this:

var baseType = typeof(WeaponGeneral);
var assembly = baseType.Assembly;
var types = assembly.GetTypes().Where(t => t.IsSubclassOf(baseType));

int numberOfTypes = types.Count;

However, this is going to be very slow. If you really need this at runtime, I recommend running it once and caching it in an int.

If you want just the number of different fields of that type on this class, you can also do it via reflection, but it probably just makes more sense to simply throw them in a collection and count the number of elements therein.

solved by reflection field info length.

@PraetorBlue Thanks.