Calling function from inspector and saving the result

I have a number of scripts that are executed at the beginning of the scene. However, this really increases load times, and as the result is always the same, I want to execute these functions by pressing a button or something in the editor (like making lightmaps). How would I go about doing this?

A simple way, although not very flexible, is to use an editor class MenuItem script to initiate the routines that you’re now doing during your start-up. It’s one of the more useful functions in Unity and I use it quite often for this type of thing.

The unity docs for Selection.activeGameObject have a decent example script that you can follow and it’s fairly easy to understand how it works. There are a few caveats that you might need to work around, non-serialized fields and private fields come to mind but there’s usually a way to store what you need.

Thank you. :slight_smile:

Will these also be able to utilize methods like OnTriggerEnter and such? Or will I have to do some manual calculations there?