Topic: How to update a DrawingElement

I am trying to figure out how to update a drawing element after it is created.

I can create a drawingElement and save a reference to it, and update its properties, but the changes are not displayed on the map after it is initially added.

Is there any way to update a drawing element that has been added to the map after it is created? And be able to show those changes?

For example, I want to change the background color of an OnlineMapsDrawingRect.

Thanks!

Re: How to update a DrawingElement

Hello.

This is a bug in Online Maps.
Fixed. In the next version this will work correctly.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to update a DrawingElement

Gotcha. Thanks!

Re: How to update a DrawingElement

Hi there,

We have updated to the newest version, but this issue persists. The DrawingRect's color does not get changed immediately after setting it. It appears some kind of event has to occur before OnlineMaps will update or something like that. If we set the background color of a DrawingRect for example, we won't see it change until the map is clicked. For now, to get past this, when we update the color we do:

            OnlineMaps.instance.RemoveDrawingElement(drawingRect, false);
            OnlineMaps.instance.AddDrawingElement(drawingRect);

Re: How to update a DrawingElement

Hello.

Test script (works well on my side):

using UnityEngine;

public class TestRectBackground:MonoBehaviour
{
    private OnlineMapsDrawingRect rect;

    private void OnGUI()
    {
        if (GUILayout.Button("Randomize background color"))
        {
            rect.backgroundColor = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
            OnlineMaps.instance.Redraw();
        }
        if (GUILayout.Button("Randomize border color"))
        {
            rect.borderColor = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
            OnlineMaps.instance.Redraw();
        }
    }

    private void Start()
    {
        rect = new OnlineMapsDrawingRect(0, 0, 1, 1, Color.black, 3, Color.red);
        OnlineMaps.instance.AddDrawingElement(rect);
    }
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

6 (edited by bp10719 2017-03-29 16:41:40)

Re: How to update a DrawingElement

Okay gotcha. Didn't realize we would have to explicitly call OnlineMaps.instance.Redraw(). That works.

I see there is an OnlineMaps.instance.needRedraw. Maybe this could be set in a color property when the color is set. I am assuming the "needRedraw" flag will tell the map to redraw at some point, but will only happen when it gets to that point? So a lot of color changes could happen, and only one redraw would have to happen?

Re: How to update a DrawingElement

We replaced fields to properties, and now Redraw is invoked automatically.

Redraw just marks that map must be redrawed.
Drawing occurs a little bit later and once (no matter how many times you invoke Redraw).

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.