Ejemplo n.º 1
0
        public void CreateLayerPanels()
        {
            // Delete any existing panel
            foreach (var panel in _layersMap)
            {
                Destroy(panel.Value.gameObject);
            }
            _layersMap.Clear();

            // appState.layers are actually Layer script (Component)
            AppState.instance.layers.ForEach(comp =>
            {
                IVirgisLayer layer = (IVirgisLayer)comp;
                Debug.Log($"CreateLayerPanels: layer {layer.GetMetadata().Id ?? ""}, {layer.GetMetadata().DisplayName ?? ""}");
                // create a view panel for this particular layer
                GameObject newLayerPanel = Instantiate(layerPanelPrefab, transform);
                // obtain the panel script
                LayerUIPanel panelScript         = newLayerPanel.GetComponentInChildren <LayerUIPanel>();
                LayerUIContainer containerScript = newLayerPanel.GetComponentInChildren <LayerUIContainer>();
                containerScript._layersMap       = _layersMap;
                // set the layer in the panel
                containerScript.layer = layer;

                containerScript.viewLayerToggle.isOn = layer.IsVisible();

                _layersMap.Add(Guid.NewGuid(), panelScript);
                newLayerPanel.transform.SetParent(layersScrollView.transform, false);
            });
            LayoutRebuilder.MarkLayoutForRebuild(transform as RectTransform);
        }
Ejemplo n.º 2
0
        private void CreateLayerPanels()
        {
            GameObject newLayerPanel;

            // appState.layers are actually Layer script (Component)
            _appState.layers.ForEach(comp =>
            {
                // obtain the actual Layer object
                //                ILayer layer = comp.GetComponentInChildren<ILayer>();
                IVirgisLayer layer = (IVirgisLayer)comp;
                print($"CreateLayerPanels: layer {layer.GetMetadata().Id ?? ""}, {layer.GetMetadata().DisplayName ?? ""}");
                // create a view panel for this particular layer
                newLayerPanel = (GameObject)Instantiate(layerPanelPrefab, transform);
                // obtain the panel script
                LayerUIPanel panelScript = newLayerPanel.GetComponentInChildren <LayerUIPanel>();
                // set the layer in the panel
                panelScript.layer = layer;
                // listens to panel's edit selected event
                panelScript.AddEditSelectedListener(OnLayerPanelEditSelected);
                if (layer.IsEditable())
                {
                    panelScript.editLayerToggle.isOn = true;
                }
                panelScript.viewLayerToggle.isOn = layer.IsVisible();
                // when the Layers Menu screen is first displayed,
                // edit session could already be active
                if (_appState.editSession.IsActive())
                {
                    // in edit session, layer can be set to edit
                    panelScript.editLayerToggle.interactable = true;
                }
                else
                {
                    // not in edit session, layer cannot be set to edit
                    panelScript.editLayerToggle.interactable = false;
                }
                _layersMap.Add(layer.GetId(), panelScript);
                newLayerPanel.transform.SetParent(layersScrollView.transform, false);
            });
            printEditStatus();
        }
Ejemplo n.º 3
0
 private void OnLayerPanelEditSelected(LayerUIPanel layerPanel, bool selected)
 {
     if (selected)
     {
         IVirgisLayer oldEditableLayer = _appState.editSession.editableLayer;
         _appState.editSession.editableLayer = layerPanel.layer;
         if (oldEditableLayer != null)
         {
             _layersMap[oldEditableLayer.GetId()].editLayerToggle.isOn = false;
         }
     }
     else
     {
         IVirgisLayer oldEditableLayer = _appState.editSession.editableLayer;
         _appState.editSession.editableLayer = null;
         if (oldEditableLayer != null)
         {
             _layersMap[oldEditableLayer.GetId()].editLayerToggle.isOn = false;
         }
     }
     //printEditStatus();
 }