Passing script type in editor instead of an instance of that scripttype

Hello people!

So to explain my problem:

I have a questhandler which contains quests thoose quests contains quest part scripts. The advantage of this is that you can make any kind of quest from the editor. I want to make the last quest part a “quest completed”.

Since the public quest_part would wait for a quest part instance but I can’t afford to have a loaded instance of all my items as quest rewards in the DontdestroyOnLoad scene

Question is: Can I pass the reward item script as a type (from the editor) not instantiated and make an instance of that in code later?

Also it would be the best if i wouldn’t have to use the base_item but it would accept the specific ones eg sword1 : base_item

Thanks in advance!

You can’t pass System.Type through the inspector, but instead, you could do something like

public class SomeClass : MonoBehaviour
{
    public Object scriptFile;

     public System.Type ScriptType {
         get{ return scriptFile.GetType(); }
     }
}

The actual class which represents a script asset (MonoScript) is an editor class which can’t be used at runtime. It’s part of the Unity editor. However you can create a propertydrawer which allows dragging MonoScripts onto string variables in the editor. So it actually just stores the class name of the class defined by the MonoScript that was dragged onto the field.