Topic: Setting marker color at runtime?

Hello,

I have seen there is a way to "get colors" from OnlineMapsMarker. What are these colors about? More generally, is there an easy way to apply a color on marker textures (at creation? at runtime?), similarly to what can be done with UI ImageRaw and Image? If not, i could probably go with something like that. https://gamedev.stackexchange.com/quest … -texture2d

Context: I m working on a theme-able interface in a flat design approach, to allow many themes to be designed for many contents of different origins. So for the UI side, i m using greyscale sprites, and just apply a color on top of them, and the result is fine. Would be great if i could extend this approach to onlineMaps markers.

Thanks.

Re: Setting marker color at runtime?

Hello.

The best way is to use 3D markers (which look like 2D markers) or UI markers.
In this case, you can change marker color directly in renderer or UI Image / RawImage.

For 2D markers, unfortunately you can only set a new texture like in your link.

Kind Regards,
Infinity Code Team.

uContext is Editor PowerPack (more than 50 tools) that take your workflow in Unity Editor to a next level, simplifies working with content, adds new features, corrects and improves the editor’s built-in behaviors. Click here to download uContext Basic for free.

Re: Setting marker color at runtime?

Hi!

I want to plot points on a map and color them depending on a specific value.

Here is my code:

        foreach (KeyValuePair<int, Data> p  in Dataset)
        {
            OnlineMapsMarker3D newMarker = MarkerController.Create(p.Value.Longitude, p.Value.Latitude, Marker_Dot);
            newMarker.scale = 6f;
            newMarker.transform.gameObject.GetComponent<MeshRenderer>().material.SetColor("_Color", Color_red);
        }

Is this the correct approach? Because the markers are not red but white. If I select one of them and check the material, the diffuse color is white. If I click on the color and the color picker opens, I can see that actually the correct color is selected here. If I pick the color from the picker and close it, the color is displayed correctly. So I assumed that you maybe need to call something on the map component to update the markers?

Thanks for your help!
Danish

Re: Setting marker color at runtime?

Hello.

Yes, this is the correct way and it works on my side (just checked).

Kind Regards,
Infinity Code Team.

uContext is Editor PowerPack (more than 50 tools) that take your workflow in Unity Editor to a next level, simplifies working with content, adds new features, corrects and improves the editor’s built-in behaviors. Click here to download uContext Basic for free.

Re: Setting marker color at runtime?

You are right. Was user's fault....
I created random colors between 0f and 255f but it should be between 0f and 1f.
Sorry and thanks!