Skip to content

Instantly share code, notes, and snippets.

@PabloAlexandre
Created October 15, 2016 04:20
Show Gist options
  • Select an option

  • Save PabloAlexandre/6368007ad7df1cce8c4bd5f939afc13e to your computer and use it in GitHub Desktop.

Select an option

Save PabloAlexandre/6368007ad7df1cce8c4bd5f939afc13e to your computer and use it in GitHub Desktop.
using UnityEngine;
public class IsometricMap : MonoBehaviour {
public Texture2D pattern;
public int pixelToUnit = 100;
public Vector2 pixelSize = new Vector2(64, 64);
public Vector2 markerPosition;
void OnDrawGizmosSelected() {
drawIcon(markerPosition, pixelSize, pixelToUnit);
}
public void drawIcon(Vector3 markerPosition, Vector2 pixelSize, int pixelToUnit){
Gizmos.DrawLine(new Vector3(markerPosition.x — (pixelSize.x * 0.5f) / pixelToUnit, markerPosition.y, markerPosition.z),
new Vector3(markerPosition.x, markerPosition.y + (pixelSize.y * 0.25f) / pixelToUnit, markerPosition.z));
Gizmos.DrawLine(new Vector3(markerPosition.x — (pixelSize.x * 0.5f) / pixelToUnit, markerPosition.y, markerPosition.z),
new Vector3(markerPosition.x, markerPosition.y — (pixelSize.y * 0.25f) / pixelToUnit, markerPosition.z));
Gizmos.DrawLine(new Vector3(markerPosition.x + (pixelSize.x * 0.5f) / pixelToUnit, markerPosition.y, markerPosition.z),
new Vector3(markerPosition.x, markerPosition.y + (pixelSize.y * 0.25f) / pixelToUnit, markerPosition.z));
Gizmos.DrawLine(new Vector3(markerPosition.x + (pixelSize.x * 0.5f) / pixelToUnit, markerPosition.y, markerPosition.z),
new Vector3(markerPosition.x, markerPosition.y — (pixelSize.y * 0.25f) / pixelToUnit, markerPosition.z));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment