public void DisplayScreen(UIScreens screenID) { HideAllScreens(); var screen = GetScreen(screenID); screen.Show(); }
public void SwitchToUI(UIScreens newUI) { //Deactivate Old switch (currentUI) { case UIScreens.GameUI: gameUI.gameObject.SetActive(false); break; case UIScreens.MainMenuUI: mainMenu.gameObject.SetActive(false); break; } currentUI = newUI; //Enable the new switch (currentUI) { case UIScreens.GameUI: gameUI.gameObject.SetActive(true); //Default Game UI Screen gameUI.ChangeToScreen(GameUI.GameScreens.GameUIScreen); break; case UIScreens.MainMenuUI: mainMenu.gameObject.SetActive(true); //Default UI Screen mainMenu.ChangeScreen(MainMenu.Screens.MainMenu); break; } }
public void ChangeScreen(UIScreens screen) { screens[(int)currentScreen].SetActive(false); screens[(int)screen].SetActive(false); switch (screen) { case UIScreens.Idle: break; case UIScreens.Settings: break; case UIScreens.Shop: break; case UIScreens.Playing: break; case UIScreens.AdScreen: break; case UIScreens.WinScreen: break; case UIScreens.FailScreen: break; case UIScreens.ChestScreen: break; default: break; } }
private void ChangeScreen(UIScreens screen) { AppLogger.Instance.LogBegin(this.GetType().Name, System.Reflection.MethodInfo.GetCurrentMethod().Name); switch (screen) { default: case UIScreens.Home: MainContent = new HomeViewModel(); break; case UIScreens.Roles: MainContent = new RoleViewModel(); break; case UIScreens.Employees: MainContent = new PersonViewModel(); break; case UIScreens.Settings: SettingsViewModel Vm_Settings = new SettingsViewModel() { SelectedUIMode = CurrentUIMode, SelectedLocale = CurrentLocale }; MainContent = Vm_Settings; break; } RaisePropertyChanged("MainContent"); AppLogger.Instance.LogEnd(this.GetType().Name, System.Reflection.MethodInfo.GetCurrentMethod().Name); }
private void Start() { if (instance == null || instance == this) { instance = this; } else { DestroyImmediate(this); } mainMenu.gameObject.SetActive(false); gameUI.gameObject.SetActive(false); switch (startingUI) { case UIScreens.GameUI: gameUI.gameObject.SetActive(true); break; case UIScreens.MainMenuUI: mainMenu.gameObject.SetActive(true); break; } currentUI = startingUI; }
public GameObject openUIScreen(UIScreens uiName, params GameObject[] objRefs) { Debug.Log("Opening UI Screen: " + uiName); // if there is a UI already open, close it if (currentUI != null) { Debug.Log("Closing UI Panel"); closeCurrentUI(); } Vector3 placeAt = getLocationForUIPanel(); GameObject curUIObject = uiObjects[uiName]; // instantiate the prefab, then set it to the current UI in use currentUI = Instantiate(curUIObject, placeAt, Quaternion.identity); ISceneUIMenu ui = currentUI.GetComponent <ISceneUIMenu>(); currentUI.gameObject.transform.LookAt(Camera.main.transform.position); currentUI.transform.eulerAngles += 180f * Vector3.up; currentUI.transform.Rotate(-currentUI.transform.eulerAngles.x, 0, 0); if (ui != null) { ui.init(objRefs); } else { Debug.LogError("Expected UI object as ISceneUIMenu type, but did not get it."); } return(currentUI); }
public void SetScreen(UIScreens screen) { if (screen == UIScreens.None) { if (currentScreen != null) { currentScreen.Close(); return; } } if (!uiScreens.ContainsKey(screen)) { Debug.Log($" # -UI- # Screen not defined for screen type: `{screen}`"); return; } var newScreen = uiScreens[screen]; if (currentScreen == newScreen) { return; } if (currentScreen != null) { currentScreen.Close(); } currentScreen = newScreen; currentScreen.Open(); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { InitializeCommands(); RegisterGalasoftMessageHandlers(); MainContent = new HomeViewModel(); SelectedScreen = UIScreens.Home; RaisePropertyChanged("SelectedScreen"); ShowMsgBox = false; RaisePropertyChanged("ShowMsgBox"); }
private UIScreen GetScreen(UIScreens type) { screens.TryGetValue(type, out var theOut); if (theOut is null) { Debug.Log("Could find screen:" + type); return(null); } return(theOut); }
private void DisplayUIScreen(UIScreens displayScreenID) { // if last screen was if (currentScreen == UIScreens.Game && displayScreenID != UIScreens.Game) { GameManager.ExitGame(); } if (displayScreenID == UIScreens.LevelChooser) { ShowLevelChooser(); } currentScreen = displayScreenID; }
public void Show(UIScreens screen) { UIScreen newUIScreen = screens.FirstOrDefault(x => x.Screen == screen); if (newUIScreen == null) { return; } if (currentUIScreen != null) { currentUIScreen.Hide(); } newUIScreen.Show(); currentUIScreen = newUIScreen; }
/// <summary> /// Loads the desired screen if not already loaded and then switches to that screen in UI view if switchToScreenOnLoad is true. /// </summary> /// <param name="screenToLoad">Screen to load.</param> /// <param name="switchToScreenOnLoad">If set to <c>true</c> switch to screen on load.</param> public void LoadScreen(UIScreens screenToLoad, bool switchToScreenOnLoad = true) { bool screenPreviouslyLoaded = false; // Check all screen names in LoadedScreenNames list to make sure this screen hasn't already been loaded previously. if (LoadedScreenNames.Count > 0) { foreach (string screenName in LoadedScreenNames) { if (screenName == screenToLoad.ToString()) { screenPreviouslyLoaded = true; } } } // If the screen hasn't been loaded previously, then load it and make it a child of the _UIScreenLayer. if (!screenPreviouslyLoaded) { GameObject screen = Instantiate(Resources.Load(UI_SCREEN_PREFABS_PATH + screenToLoad.ToString(), typeof(GameObject))) as GameObject; if (screen != null) { RectTransform screenRect = screen.GetComponent <RectTransform> (); if (screenRect != null) { screenRect.transform.SetParent(_UIScreenLayerRect.transform, true); screenRect.transform.localPosition = Vector3.zero; screenRect.transform.localScale = Vector3.one; } } // Toggle the loaded screen either active or inactive. screen.gameObject.SetActive(switchToScreenOnLoad); LoadedScreenNames.Add(screenToLoad.ToString()); Debug.LogFormat("{0} screen has been loaded.", screenToLoad.ToString()); } else { Debug.LogErrorFormat("{0} screen has been previously loaded. Cannot load again!", screenToLoad.ToString()); } }
protected void Awake() { Button[] buttonComponents = Resources.FindObjectsOfTypeAll <Button>(); if (buttonComponents.Length > 0) { for (int i = 0; i < buttonComponents.Length; i++) { if (buttonComponents[i].name.Contains("Btn")) { buttonComponents[i].onClick.RemoveAllListeners(); buttonComponents[i].onClick.AddListener(OnClickButton); } } } if (m_screens == null) { m_screens = new UIScreens(); } m_screens = m_isPortrait ? m_portraitScreens : m_landscapeScreens; SetScreen(m_screens.title); }
public void AddUIScreen(string name, UIScreen uiScreen) { uiScreen.Initialize(); UIScreens.Add(name, uiScreen); }
// Start is called before the first frame update void Awake() { instance = this; cam = Camera.main; }