BorisKotlyar

Untitled

Feb 18th, 2020
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using IngradBi.Prezentation.KPI;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. namespace IngradBi.IngradPrezentationMode.ProjectPassport
  7. {
  8.     public class ProjectPanelViewController : MonoBehaviour
  9.     {
  10.         [SerializeField] private Toggle _toggle;
  11.         [SerializeField] private GameObject _passportPanel;
  12.         [SerializeField] private GameObject _statsPanel;
  13.        
  14.         [Header("Stats Panel")]
  15.         [SerializeField] private BottomToggleGroup _toggleGroup;
  16.         [SerializeField] private List<Canvas> _statsPanels;
  17.  
  18.         private void Awake()
  19.         {
  20.             _passportPanel.SetActive(false);
  21.             _statsPanel.SetActive(true);
  22.  
  23.             _toggle.onValueChanged.AddListener(isOn =>
  24.             {
  25.                 _passportPanel.SetActive(isOn);
  26.                 _statsPanel.SetActive(!isOn);
  27.             });
  28.            
  29.             _toggleGroup.OnChangeSelected += StatsPanelChange;
  30.         }
  31.        
  32.         private void StatsPanelChange(int panelId)
  33.         {
  34.             for (var i = 0; i < _statsPanels.Count; i++)
  35.             {
  36.                 _statsPanels[i].enabled = i == panelId;
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment