How can you calculate and save data for certain objects in editor?

I am working with a 2D cablesimulation for my game. For this I need the convex hull and some other parameters for every object the cable can interact with.
I could just let every object calculate their convex hull in the start. But I feel it is a bit unnecessary to recalculate every object everytime you start up the game.
I’m sure there is a way to script so you can generate the necessary information in the editor and save it for each object. I am a totall noob in custom editors and whatnot so I don’t even know what to search for.

Any help of how to do this or where I should look for the information would be greatly appreciated.

You are going to need to have a field to store the data in that is serialized and a function to calculate the hull with the [ContextMenu] attribute over it so you can execute the code in the editor easily. It should be pretty straight forward if you are representing the hull with a data type that Unity already serializes.

2 Likes

Thank you so much. This seems to be just what I needed.

Great! I am glad to help.