SHARE
TWEET

Untitled

Neozman Mar 18th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using UnityEngine;
  4. using System.Collections;
  5. using UnityEngine.UI;
  6.  
  7. public class CustomTabs : MonoBehaviour
  8. {
  9.     public List<CustomTab> _customTabs;
  10.     public ToggleGroup _toogleGroup;
  11.  
  12.     public List<CustomTab> GetListCustomTabs()
  13.     {
  14.         return _customTabs;
  15.     }
  16.  
  17.  
  18.     void Start ()
  19.     {
  20.         if (_toogleGroup == null)
  21.             _toogleGroup = GetComponent<ToggleGroup>();
  22.     }
  23.    
  24.  
  25.     void Update ()
  26.     {
  27.         if (_toogleGroup == null)
  28.             return;
  29.  
  30.         if (_toogleGroup.AnyTogglesOn())
  31.         {
  32.             int length = _customTabs.Count;
  33.             for (int i = 0; i < length; i++)
  34.             {
  35.                 CustomTab tab = _customTabs[i];
  36.                 tab.Active = false;
  37.             }
  38.  
  39.             Toggle activeTab = _toogleGroup.ActiveToggles().First();
  40.             if (activeTab != null)
  41.             {
  42.                 CustomTab group = activeTab.GetComponent<CustomTab>();
  43.                 if (group != null)
  44.                     group.Active = true;
  45.             }
  46.         }
  47.     }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top