UGUI MiniMap Dynamically set MapTexture

General support.
Post Reply
User avatar
SureSight
New Member
New Member
Posts: 7
Joined: Wed Dec 16, 2015 4:35 am

We are using the minimap in the Picture mode and I am hoping to change the MapTexture whenever I load a new level or step inside a house/cave
Just setting the bl_MiniMap.MapTexture does not work as it needs to call CreateMaterial() for the plane

Please advise how I might update the MapTexture on the fly.
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Hi for do this you will need modify a little the code I will guide you:
in bl_MiniMap.cs add this private var:

Code: Select all

private GameObject plane;
now in the funtion void CreateMapPlane() find this line:

Code: Select all

GameObject plane = Instantiate(MapPlane) as GameObject;
and replace with this:

Code: Select all

plane = Instantiate(MapPlane) as GameObject;
and add this new funtion:

Code: Select all

    /// <summary>
    /// 
    /// </summary>
    /// <param name="t"></param>
    public void SetMapTexture(Texture t)
    {
        if(m_Type != RenderType.Picture)
        {
            Debug.LogWarning("You only can set texture in Picture Mode");
            return;
        }
        plane.GetComponent<MeshRenderer>().material.mainTexture = t;
    }
now you can change the map texture like this:

Code: Select all

bl_MiniMapUtils.GetMiniMap().SetMapTexture(YourTexture);
I hope this help you.
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
SureSight
New Member
New Member
Posts: 7
Joined: Wed Dec 16, 2015 4:35 am

Works like a charm!

Could we ask that you include this change in the next version?
Post Reply