ExecuteInEditMode, executing a separate class on the same script?

I need two methods in a class to execute in edit mode to grab an object reference (so I don’t have to play the drag and drop game). So I made a small class inside the same script that does what I want and set [ExecuteInEditMode] on it. However it does not seem to actually execute, only the class with the same name as the script executes.

Is there a way to accomplish this without having to add another component to my game object for a measly 7 lines of code?

Just set [ExecuteInEditMode] on your “real” class. There’s generally no harm in having that, even for classes whose primary purpose is runtime.

And yeah, a “component” that Unity’s going to know anything about is a class (that derives from MonoBehaviour) in a file of the same name as the class. So you can’t have two components in one file.