I’m quite new here, sorry if I say anything crazy.
So, I have a bunch of data (position, vertices and triangles) saved and what I want to do is create a map using all this data. The think is I only want to run this script once. Using ExecuteInEditMode in Start() would do that every time I open unity, Update() would run it everytime I want to change anything in the scene and that’s not what I’m looking for. By now, I have the script in a GameObject called “map”.
I’ve tried using the Start() method but using that I have the problem that when assigning the vertices, I get a NullReferenceExeption from the new GameObject. The idea was using it once and then remove the script from the map GameObject.
The script I have now it kinda works when it’s used without the ExecuteInEditMode, the only problem I have is that the new GameObjects I don’t know why, can’t get their material changed. But that’s another problem.
Anyone has any idea of what should I do?
Thank you.
Welcome!
Methinks what you need is either a custom editor, or else just a menu item that does this import-inject-save step for you precisely when you want it to, then never again.
Here’s how to write a custom editor (it’s EASY):
https://docs.unity3d.com/Manual/editor-CustomEditors.html
Here’s how to make a custom menu item:
https://docs.unity3d.com/ScriptReference/MenuItem.html
Either way, likely you would just past 99% of your existing import code into a different way of being triggered. You can even pop up file dialogs to ask what file you want.