Pro_Unit

TabsButtonsController

Dec 9th, 2018
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. using UnityEngine;
  6. namespace GameCore
  7. {
  8.     public class TabsButtonsController : MonoBehaviour
  9.     {
  10.         List<TabButton> tabs = new List<TabButton> ();
  11.         [SerializeField] TabButton lastSelcted;
  12.         private void Start ()
  13.         {
  14.             if (lastSelcted) lastSelcted.Active = true;
  15.         }
  16.         public bool IsSelected (TabButton tabButton)
  17.         {
  18.             if (lastSelcted)
  19.                 return lastSelcted.Equals (tabButton);
  20.  
  21.             return false;
  22.         }
  23.  
  24.         public void Swith (TabButton tabButton)
  25.         {
  26.             if (lastSelcted) lastSelcted.Active = false;
  27.             lastSelcted.onDeSelect.Invoke ();
  28.             lastSelcted = tabButton;
  29.             lastSelcted.onSelect.Invoke ();
  30.             lastSelcted.Active = true;
  31.         }
  32.         public void RegistryTabButton (TabButton tabButton)
  33.         {
  34.             if (!tabs.Contains (tabButton))
  35.                 tabs.Add (tabButton);
  36.         }
  37.  
  38.         public void UnRegistryTabButton (TabButton tabButton)
  39.         {
  40.             if (tabs.Contains (tabButton))
  41.             {
  42.                 tabs.Remove (tabButton);
  43.                 tabButton.Active = tabButton.Equals (lastSelcted);
  44.             }
  45.         }
  46.  
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment