{"id":13661282,"url":"https://github.com/Amaranthos/UnityHexGrid","last_synced_at":"2025-04-24T23:32:17.941Z","repository":{"id":61930785,"uuid":"43228696","full_name":"Amaranthos/UnityHexGrid","owner":"Amaranthos","description":"A hex grid generation tool, for use in unity","archived":false,"fork":false,"pushed_at":"2019-09-22T05:46:43.000Z","size":41,"stargazers_count":223,"open_issues_count":2,"forks_count":47,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-10T15:46:01.636Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Amaranthos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-27T00:44:41.000Z","updated_at":"2024-10-11T23:39:11.000Z","dependencies_parsed_at":"2022-10-23T18:15:34.379Z","dependency_job_id":null,"html_url":"https://github.com/Amaranthos/UnityHexGrid","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amaranthos%2FUnityHexGrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amaranthos%2FUnityHexGrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amaranthos%2FUnityHexGrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amaranthos%2FUnityHexGrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Amaranthos","download_url":"https://codeload.github.com/Amaranthos/UnityHexGrid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250727797,"owners_count":21477372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T05:01:31.904Z","updated_at":"2025-04-24T23:32:17.567Z","avatar_url":"https://github.com/Amaranthos.png","language":"C#","readme":"# UnityHexGrid\nA hex grid generation tool, for use in unity. Much of the hex logic is drawn from [Red Blob Games](http://www.redblobgames.com/grids/hexagons/). I made this because I initially struggled with the implementation so now you don't have to. Feel free to leave any feedback or suggestions, I will consider implementing suggestions that I think are generally useful to all users.\n\n## Installation\nDownload unity package from releases\n\nIn unity Assets \u003e Import Package \u003e Custom Package\n\nNavigate to downloaded file and select it\n\nCreate an empty gameObject `ctrl+shift+n` and add `Grid` script to it\n\n## Generating a Grid in edit mode\nClick Generate Grid in the inspector ensuring that relevant settings are selected\n\n## Generating a Grid at runtime\nEnsure relevant settings are set and call `GenerateGrid()` on an instance of Grid\n\n```cs\npublic Material hexMaterial; //Assigned in inspector\npublic Material lineMaterial; //Assigned in inspector\n\nprivate Grid grid;\n\nprivate void Start() {\n\t//Set grid settings\n\tgrid.mapShape = MapShape.Rectangle;\n\tgrid.mapWidth = 5;\n\tgrid.mapHeight = 5;\n\tgrid.hexOrientation = HexOrientation.Flat;\n\tgrid.hexRadius = 1;\n\tgrid.hexMaterial = hexMaterial;\n\tgrid.addColliders = true;\n\tgrid.drawOutlines = true;\n\tgrid.lineMaterial = lineMaterial;\n\n\t//Gen Grid\n\tgrid.GenerateGrid();\n}\n```\n\n## Access tiles at runtime\n\nCall `Tiles` on an instance of Grid, returns a `Dictionary\u003cstring, Tile\u003e` where the string is constructed from the tile's coordinates.\n\n```cs\nprivate Grid grid;\n\nprivate void Start() {\n\tvar tiles = grid.Tiles;\n}\n\n```\n\n## Grid Settings\n* `mapShape` determines the overall shape of the map, available options are\n  * Rectangle\n   \n  ![Rectangle](http://i.imgur.com/I5eIjlu.jpg)\n  * Hexagon\n   \n  ![Hexagon](http://i.imgur.com/pvCvkuT.jpg)\n  * Parrallelogram\n   \n  ![Parrallelogram](http://i.imgur.com/ZtASYn0.jpg)\n  * Triangle\n  \n  ![Triangle](http://i.imgur.com/uOEkZKF.jpg)\n* `mapWidth` an `int`, controls the number tiles wide the map is, for hexagonal shape the larger of `mapWidth` and `mapHeight` is picked and used as a radius. \n* `mapHeight` an `int`, controls the number of tiles high the map is\n* `hexOrientation` the orientation of the individual hexes, available options are\n    * Pointy\n  ![Pointy](http://i.imgur.com/CGWnE1M.jpg)\n    * Flat\n  ![Flat](http://i.imgur.com/es0TKVS.jpg)\n* `hexRadius` a `float`, controls the radius of hex tile meshes, in unity units, measured from the centre of the hex to a corner, all corners are equidistant from the centre\n* `hexMaterial` a `Material`, applied to the hex tile meshes, if not specified defaults to unity's diffuse material\n* `addColliders` a `bool`, when true grid generation will add a mesh collider to the tiles using the same mesh as the tiles\n* `drawOutlines` a `bool`, when true grid generation will add line renderers to the tiles and draw outlines for the meshes\n* `lineMaterial` a `Material`, applied to the line renderers for drawing outlines, if you want outlines add the `Lines` material, included in the package, to the inspector field. Apparently I couldn't load the default Sprites/Default material via code\n","funding_links":[],"categories":["C\\#","Generator"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAmaranthos%2FUnityHexGrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAmaranthos%2FUnityHexGrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAmaranthos%2FUnityHexGrid/lists"}