All articles tagged as:

c#

Hex Map Area Borders

Today we're going to learn how to create a nice border around the perimeter of an area in a hex map using Unity and a LineRenderer. Here I have it as a dotted purple line but you can make it look like anything you want with the flexibility of the line renderer!The foundation of the hex code here is adapted from the Hex Map Series by Catlike Coding which has been super helpful for getting started. So if there's any bits of code I missed here it's likely from there, but please let me know in the comments if you're getting stuck or confused anywhere. First up we'll need a little background code f…

Read more »

Minimizing string GC in Unity

An easy trap to fall into when you're starting out in Unity is creating strings each frame in your update loop.  Say you have score that can change from a bunch of things: eliminating foes, jumping on a block, collecting a ring, or just existing. Whatever floats your boat.  Then in your score updater component you just do: void Update(){ textComponent.text = "Score: " + score.ToString(); }Easy and done.  Problem is, you're now creating a string (which are immutable in C# and allocate memory) each frame.  This will really add up and create lots of garbage which will need collecting.The U…

Read more »

Leaflet Zip Code Map Part 2

Leaflet Zip Code Map Part 1 In this part of the tutorial we'll be focusing on what you need to do to get a front end set up to serve up the map and consume the wonderful zip code data. In case you missed it, here's what we're going for: HTML The html required on the page is almost as basic as it gets since most stuff is loaded in dynamically. The main pieces are: The map div <div class="control" id="map-loader"></div> The Coloring function dropdown if needed And your script includes of course: I'm using Numeral.js for number formatting on the popup, d3 for the h…

Read more »

Leaflet Zip Code Map Part 1

This is the first part of a two part series about how to set up leaflet maps to show zipcode areas with some extra data coming along for the ride allowing us to color the zip code areas based on demographics or any other reporting data. I did this using an ASP.NET MVC site and Web API with a Sql Server database. A database is required for this approach but there's nothing stopping you from reimplementing this in your backend architecture of choice. Here's what it looks like sans the external controls on the page to change reporting parameters and the coloring function (more on that later).…

Read more »