Sorry for long none response..
I had questioned about mixing UGUI and Tileset-OnlineMaps.
well temporally i fixed issue myself. (Not well)
The result is this, attached image.
I changed <Canvas mode> to 'Screen Space Camera' and add <Canvas Group> to use 'Blocks Raycasts' and 'Ignore Parent Groups' to click UGUI Button when the Map active.
Everything is fine but the problem recently found...
I added custom marker on Map. When Map go Up and Down marker still active when Map didn't show marker's coordinate.
The situation is on Image. (On Map Bottom, there is flag image (marker). If I Change Marker Align Top or Bottom still this problem exist top or bottom side)
Anyway to help this problem?
You had suggested some custom line style solution.
Is only works when Tileset Map?? I added this code UIImageControl Map, but not work. (That UIImageControl Map do not have
Marker problem, but could not change Line Texture...
If possible to change line texture in UIImageControl Map, I would change TileSet Map to UIImageControl Map.
I hope you could give me any help, any advice.
Alex Vertax wrote:You can work around this in this way:
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
public class DrawLineWithTexture:MonoBehaviour
{
public Texture2D lineTexture;
private OnlineMapsMarker marker1;
private OnlineMapsMarker marker2;
private OnlineMapsDrawingLine line;
private void Start()
{
OnlineMapsControlBase.instance.OnMapClick += OnMapClick;
}
private void OnMapClick()
{
OnlineMapsMarker marker = OnlineMaps.instance.AddMarker(OnlineMapsControlBase.instance.GetCoords());
if (marker1 == null)
{
marker1 = marker;
return;
}
marker2 = marker;
List<Vector2> points = new List<Vector2>
{
marker1.position,
marker2.position
};
line = new OnlineMapsDrawingLine(points, Color.red, 10);
line.texture = lineTexture;
OnlineMaps.instance.AddDrawingElement(line);
OnlineMaps.instance.OnMapUpdated += OnMapUpdated; // Delay because the line is not yet drawn.
marker1.OnDrag += OnMarkerDrag;
marker2.OnDrag += OnMarkerDrag;
OnlineMapsControlBase.instance.OnMapClick -= OnMapClick;
}
private void OnMapUpdated()
{
UpdateUVScale();
OnlineMaps.instance.OnMapUpdated -= OnMapUpdated;
}
private void OnMarkerDrag(OnlineMapsMarkerBase marker)
{
List<Vector2> points = new List<Vector2>
{
marker1.position,
marker2.position
};
line.points = points;
UpdateUVScale();
OnlineMaps.instance.Redraw();
}
private void UpdateUVScale()
{
FieldInfo field = line.GetType().GetField("gameObject", BindingFlags.NonPublic | BindingFlags.Instance);
if (field == null)
{
Debug.Log("No field");
return;
}
GameObject lineGO = field.GetValue(line) as GameObject;
MeshFilter meshFilter = lineGO.GetComponent<MeshFilter>();
Vector3[] vertices = meshFilter.sharedMesh.vertices;
float distance = 0;
for (int i = 2; i < vertices.Length; i += 2) distance += (vertices[i - 2] - vertices[i]).magnitude;
distance /= line.width * 2;
MeshRenderer meshRenderer = lineGO.GetComponent<MeshRenderer>();
meshRenderer.sharedMaterials[0].mainTextureScale = new Vector2(1, distance);
}
}
Yes, this is a bad practice and a dirty hack, but I do not know how to do this without access to the vertices.
Theoretically, we can make gameObject field public.
Post's attachments capture2.PNG 87.12 kb, 65 downloads since 2017-08-23