private static void DisplayCharactersUsername() { Chat chat = ChatUtil.GetChat(); Prefabs prefabs = SingletonUtil.GetMain().Prefabs; InChatPanelComponent inChatPanelComponent = (InChatPanelComponent)UIPanelUtil.GetUIPanel(PanelType.IN_CHAT); if (inChatPanelComponent.CharactersUsername.Length != chat.Characters.Count) { if (inChatPanelComponent.CharactersUsername.Length > chat.Characters.Count) { int diff = inChatPanelComponent.CharactersUsername.Length - chat.Characters.Count; for (int i = diff + 1; i < inChatPanelComponent.CharactersUsername.Length; i++) { inChatPanelComponent.CharactersUsername[i].gameObject.SetActive(false); } } else { int diff = chat.Characters.Count - inChatPanelComponent.CharactersUsername.Length; for (int i = 0; i < diff; i++) { Pool.TryGetMonoBehaviourFromPool <UIText>(ref inChatPanelComponent.CharactersUsername, prefabs.UiText); } } } }
public static UIPanel GetUIPanel(PanelType panelType) { UIHolder uiHolder = UIUtil.GetUIHolder(); UIPanel uiPanel = null; Prefabs prefabs = SingletonUtil.GetMain().Prefabs; switch (panelType) { case PanelType.LOGIN: { if (uiHolder.LoginPanelComponent == null) { uiHolder.LoginPanelComponent = GameObject.Instantiate(prefabs.LoginPanelComponent, uiHolder.Canvas.transform); uiHolder.InstantiatedPanels.Add(uiHolder.LoginPanelComponent.PanelType); } uiPanel = uiHolder.LoginPanelComponent; } break; case PanelType.LOGIN_SETTINGS: { if (uiHolder.LoginSettingsPanelComponent == null) { uiHolder.LoginSettingsPanelComponent = GameObject.Instantiate(prefabs.LoginSettingsPanelComponent, uiHolder.Canvas.transform); uiHolder.InstantiatedPanels.Add(uiHolder.LoginSettingsPanelComponent.PanelType); } uiPanel = uiHolder.LoginSettingsPanelComponent; } break; case PanelType.CONNECTING: { if (uiHolder.ConnectingPanelComponent == null) { uiHolder.ConnectingPanelComponent = GameObject.Instantiate(prefabs.ConnectingPanelComponent, uiHolder.Canvas.transform); uiHolder.InstantiatedPanels.Add(uiHolder.ConnectingPanelComponent.PanelType); } uiPanel = uiHolder.ConnectingPanelComponent; } break; case PanelType.HUB: { if (uiHolder.HubPanelComponent == null) { uiHolder.HubPanelComponent = GameObject.Instantiate(prefabs.HubPanelComponent, uiHolder.Canvas.transform); uiHolder.InstantiatedPanels.Add(uiHolder.HubPanelComponent.PanelType); } uiPanel = uiHolder.HubPanelComponent; } break; case PanelType.IN_CHAT: { if (uiHolder.InChatPanelComponent == null) { uiHolder.InChatPanelComponent = GameObject.Instantiate(prefabs.InChatPanelComponent, uiHolder.Canvas.transform); uiHolder.InstantiatedPanels.Add(uiHolder.InChatPanelComponent.PanelType); } uiPanel = uiHolder.InChatPanelComponent; } break; } uiPanel.transform.position = uiHolder.Camera.WorldToScreenPoint(Vector3.zero); return(uiPanel); }