예제 #1
0
    public static void ShowTab(NetTabType type, GameObject tabProvider, ElementValue[] elementValues)
    {
        if (tabProvider == null)
        {
            return;
        }
        if (!Instance.rolledOut)
        {
            Instance.StartCoroutine(Instance.AnimTabRoll());
        }

        var openedTab = new NetTabDescriptor(tabProvider, type);

        //try to dig out a hidden tab with matching parameters and enable it:
        if (Instance.HiddenNetTabs.ContainsKey(openedTab))
        {
//				Logger.Log( $"Yay, found an old hidden {openedTab} tab. Unhiding it" );
            Instance.UnhideTab(Instance.HiddenNetTabs[openedTab]);
        }
        if (!Instance.OpenedNetTabs.ContainsKey(openedTab))
        {
            var        rightPanelParent = Instance.TabStorage;
            NetTab     tabInfo          = openedTab.Spawn(rightPanelParent);
            GameObject tabObject        = tabInfo.gameObject;

            //putting into the right place
            tabObject.transform.localScale = Vector3.one;
            var rect = tabObject.GetComponent <RectTransform>();
            rect.offsetMin = new Vector2(15, 15);
            rect.offsetMax = -new Vector2(15, 50);

            Instance.RefreshTabHeaders();
        }

        NetTab tab = Instance.OpenedNetTabs[openedTab];

        tab.ImportValues(elementValues);
        Instance.SelectTab(tab.gameObject, false);
    }