public class variable in inspector like other components?

Is it possible to declare a public class variable in a script in which you can simply drag any class you wish into it?
For example, when you declare:
“public Gameobject objectname” you can drag any gameobject into it to use, is it possible to do the same sort of thing but with scripts of any type?

Yes, you can simply define a variable either of type “Component” which would allow any component to be assigned (so script as well as Renderer, Rigidbody, Collider, …) or if you only want to allow script use “MonoBehaviour” as type.

You can also provide a base class yourself. You can assign only derived classes to that variable.

Keep in mind that when using Component or MonoBehaviour you can’t access anything specific from the actual assigned class. You can only access what the Component base class or the MonoBehaviour base class provides. If you need anything script specific you would need to cast the reference to the actual type.