I am creating a hex-grid for my game map. Hexagons are objects whose member variable values I want to store. However, I want to store them at design time, not runtime. I am slowly figuring out how to create an editor script to run the calculations that generate the hexagonal game map. How do I store the data that those calculations will produce when it is done calculating?
I’m not sure what you are positioning (tile object, grid positions…) and what calculations you need to do to generate the data. It is often possible to store structured data in arrays or serialisable classes but perhaps you can give a little more detail to narrow down exactly how you might go about it.
I’m not sure if this is the same thing, but I have also used a script to create a hexagonal grid of instanced objects as the game runs and would love a way to store those objects in a prefab. Is it possible to pause the game, select the objects and put them in a prefab?
Hm… maybe I should try that!
You don’t even need to pause.
Indeed!
Personally I just select some game object in the prefab and hit option-command-A, which I set to trigger “Apply Changes to Prefab”.
Andeeee, I’m wanting to store the center points of each hexagon relative to the terrain, a “side” object that holds the endpoints for each side, as well as the adjacent hexagons for each hexagon. Right now, it calculates all of this stuff when you start the game. I was hoping to be able to just pre-calculate and store all of that information so it doesn’t have to initialize every time the game starts. Basically, I created a Hexagon class that holds all of this information. There is no gameobject in use. It is all just data that I want to save once rahter than initializing it all every time the application starts.
I suppose I could just run the game, save the data to a file, and then reference that file to be loaded when the game starts.