Select to view content in your preferred language

Remove layer with button - Unity VR

780
2
Jump to solution
11-22-2022 03:32 PM
WH1981
by
Regular Contributor

Hello,

I made a button on a panel and when i push the button i wanna remove a layer.

WH1981_0-1669159309862.png

the Onclick function on the button. But i don't know the workaround of this.

WH1981_1-1669159603479.png

The script that must run on click button to remove a layer:

WH1981_3-1669159669199.png

can someone help me

0 Kudos
1 Solution

Accepted Solutions
StephenNauman
Esri Contributor

You're pretty close. Change: 

void Update()

to:

public void RemoveLayer()
{
    Debug.Log("Remove Layer");
    ArcGISMap.Layers.Remove(my_layer);
}

You'll find the function in the button dropdown list that you circled under "No Function". Press play and click the button to see results

View solution in original post

0 Kudos
2 Replies
StephenNauman
Esri Contributor

You're pretty close. Change: 

void Update()

to:

public void RemoveLayer()
{
    Debug.Log("Remove Layer");
    ArcGISMap.Layers.Remove(my_layer);
}

You'll find the function in the button dropdown list that you circled under "No Function". Press play and click the button to see results

0 Kudos
WH1981
by
Regular Contributor

Hello,

I have a update:

Its working now that i remove a layer in Play modus, but the Map rebuilds and ArcGIS tells this:

https://developers.arcgis.com/unity/layers/

WH1981_0-1669966431908.png

This is my code:

The var ArcGISMap is not public i think. I need push the function public void CreateArcGISMap() to remove a layer. But i don't want to rebuild the map.

WH1981_1-1669966463651.png

Or is this not possible?

ps: laag_2.Opacity = 0.1f; is not working.

0 Kudos