Assigning references quicker through script

Can I utilize editor scripting to assign object references quicker than doing it by drag and drop?

I know how to get these items by searching for them, but storing them as references outside of runtime would be better.

I have a rough idea how to do this, but what function do I use — OnInspectorGUI() or something else?

I found I could use either Awake() or OnInspectorGUI() for this. As a quick reference for anyone else, this was my little script:

@CustomEditor (LevelScreen)

class LevelScreen_autoAssign extends Editor
{
	function Awake()
	{
		for (var i=0; i < target.levelIcons.Count; i++)
		{
			for (var j=0; j < target.levelIcons*.areaIcons.Count; j++)*
  •  	{*
    

if ( target.levelIcons_.areaIcons[j].main != null && target.levelIcons*.areaIcons[j].highlight == null )
{
var icon = target.levelIcons.areaIcons[j].main.transform;
target.levelIcons.areaIcons[j].highlight = icon.Find(“highlight”).gameObject;_

target.levelIcons.areaIcons[j].locationIcon = icon.Find(“location_icon”).gameObject.renderer;
target.levelIcons.areaIcons[j].gameIcon = icon.Find(“game_icon”).gameObject.renderer;
_ target.levelIcons.areaIcons[j].progressDisc = icon.Find(“progressDisc”).gameObject.renderer;
}
}
}
}
}*

Awake() is called each time you select the item in the Heirarchy. So once you’ve assigned the initial reference, click off the object, then back onto it and it will grab all the other references automatically. After which I just commented out the editor script as I don’t feel I would need it after this.
Instead of putting it in Awake(), using OnInspectorGUI would work too and would do a check every few milliseconds so would grab the references immediately but would make the default inspector disappear. To avoid this, I used the Awake() method but another option if you want immediate updating is to add DrawDefaultInspector () into OnInspectorGUI()._