- Home /
possible to add to a texture through code?
Hey guys, I have a hexagon gridmap for my game, i want it to default to invisible, but then have a toggle button to change the material to outline the hexagons. I have managed to do this... but even on my smallest map there is 2500 hexagons... so there's a bit of a delay between pressing the button and them disappearing.
So i thought, the hexagons are parented to a grid object... would it be possible for me to create a texture for the hexgrid based on all the hexagon textures? Similar to how you might create a mesh out of the meshes of seperate objects that already exist.
I'm not expecting there to be... just very hopeful, 'cause changing the hexgrid material from opaque to transparent and back would take a fraction of the time of doing it for all hexagons.
Alternatively does any one know of another way i can cut out the delay time?
Thanks all.
Answer by Piesk · Dec 06, 2013 at 07:44 PM
I have managed to find a solution to this, went out to walk the dogs and get some fresh air, and a solution so simple i'm amazed it didn't occur to me before presented itself.
To any trying to do something similar this is what i did:
Duplicated hexagon prefab, set the duplicate as a child to the original, turn off the renderer of the parent, set the child to be in a separate layer. Use the button to toggle that layer on and off from the cameras culling mask =). Hope that helps some one.
Your answer
![](https://koobas.hobune.stream/wayback/20220613123550im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Good uv mapping tutorial? 1 Answer
3D RenderTextures with Depth Not Supported (worked in <=2017.1, broken 2018+) 1 Answer
Syncing up procedurally generated textures... where am I wrong? 0 Answers
How to load a PNG into texture2d without extra memory? 1 Answer
Fastest way to load a Texture2D in Unity (web player)? 0 Answers