public void Draw(GUIMap map, Rect area) { UpdateValues(); var center = map.PixelToRelative(GM.MetersToPixels(GM.LatLonToMeters(position.x, position.y), map.Zoom)).ToVector2(); if (Texture != null) { var size = new Vector2(Texture.width, Texture.height); // Scale of 1 means 1 pixel is 1 map pixel in scale 19 // Scale of 2 means 1 pixel is 0.5 map pixel in scale 18 // and so on... var pixelsSize = GM.MetersToPixels(GM.PixelsToMeters(new Vector2d(size.x * scale.x, size.y * scale.y), 19), map.Zoom); var midWidthHeight = pixelsSize.ToVector2() / 2f; var textRect = ExtensionRect.FromCorners(center - midWidthHeight, center + midWidthHeight); /*var areaRect = textRect.Intersection(area); * GUI.DrawTextureWithTexCoords(areaRect, i, textRect.ToTexCoords(areaRect));*/ GUI.DrawTexture(textRect, Texture); Handles.BeginGUI(); var influencePixels = map.PixelToRelative(GM.MetersToPixels(GM.LatLonToMeters(position.x, position.y) + new Vector2d(interactionRange, 0), map.Zoom)).ToVector2() - center; Handles.color = Color.black; Handles.DrawWireArc(center, Vector3.back, Vector2.up, 360, influencePixels.magnitude); Handles.EndGUI(); } }
public void Draw(GUIMap map, Rect area) { UpdateValues(); var degree = this.degree * Mathf.Deg2Rad; var center = (map.Center + GM.MetersToLatLon(new Vector2d(distance * Mathd.Sin(degree), distance * Mathd.Cos(degree)))).ToVector2(); center = map.PixelToRelative(GM.MetersToPixels(GM.LatLonToMeters(center.x, center.y), map.Zoom)).ToVector2(); if (Texture != null) { var size = new Vector2(Texture.width, Texture.height); // Scale of 1 means 1 pixel is 1 map pixel in scale 19 // Scale of 2 means 1 pixel is 0.5 map pixel in scale 18 // and so on... var pixelsSize = GM.MetersToPixels(GM.PixelsToMeters(new Vector2d(size.x * scale.x, size.y * scale.y), 19), map.Zoom); var midWidthHeight = pixelsSize.ToVector2() / 2f; var textRect = ExtensionRect.FromCorners(center - midWidthHeight, center + midWidthHeight); /*var areaRect = textRect.Intersection(area); * GUI.DrawTextureWithTexCoords(areaRect, i, textRect.ToTexCoords(areaRect));*/ GUI.DrawTexture(textRect, Texture); } }