- Home /
Best approach to one-time generation: Assets, Serialization or manual labor?
What I want to achieve is this: A one-time generation of an X by Y field of gameobjects (tiles in a grid, basically). Afterwards I would like to be able to adjust the X or Y by using an editor window or inspector panel.
Making a script to generate a grid of items is easy. Now I want the tiles to stay in place after assembly reload. Or even when I reopen the project.
However I am lost to what is the best approach to this. Is it by using prefabs/resources and creating individual assets? Running the script only once?
Or perhaps through a serialized list of gameobjects which will use OnEnable to check if the required X and Y tiles are there?
I can manually place each item on each gridpoint (and adjust each item's name) but understandibly that should be a chore left unnecessary.
Which is the best avenue to go down? Thank you.
Answer by Owen-Reynolds · Mar 10, 2014 at 11:11 PM
I'm thinking a Unity "editor script" can make permanent changes to objects. In theory your current grid placement code would be translated into one of these. Might end up with a custom Inspector for a "gridScript" object, with a slider for size, etc... . Any cool packages with funny-looking Inspector panels were made that way.
They are a pain to figure out, lots of magic words, but I think the sort of thing that once you know how, you want to make one for everything.
Thanks. It would seem so, wouldn't it? What I have been struggling with, though, is using prefabs in unapplied scripts. But perhaps the /resource folder might help with that.
Right now I think the best avenue is that of trying to instantiate real objects: IE, assets. Therefor I am investigating this package by $$anonymous$$ike "@runonthespot" http://forum.unity3d.com/threads/175168-Scriptable-Object-simplest-use
Your answer
Follow this Question
Related Questions
Saving runtime created avatar 1 Answer
Serialization with custom editor, prefab not saving (again) 1 Answer
FormerlySerializedAs and Prefabs 0 Answers
How to Load/Unload assets in Editor? 0 Answers