// Start is called before the first frame update void Start() { rect = GetComponent <RectTransform>(); // initialize moveTween to some value moveTween = rect.DOScale(1f, 0.001f); mainMenu = FindObjectOfType <MainMenuManager>(); teamSelect = FindObjectOfType <TeamSelectManager>(); helpScreen = FindObjectOfType <HelpScreenManager>(); levelSelect = FindObjectOfType <LevelSelectManager>(); mainMenu.SetAsActive(true); teamSelect.SetAsActive(false); helpScreen.SetAsActive(false); levelSelect.SetAsActive(false); }
public void ChangeToScreen(Screen newScreen) { if (moveTween.IsPlaying()) { return; } Vector2 targetPos = Vector2.zero; switch (newScreen) { case Screen.MAINMENU: targetPos = Vector2.zero; break; case Screen.TEAMSELECT: targetPos = new Vector2(-1920, 0); break; case Screen.LEVELSELECT: targetPos = new Vector2(-1920 * 2, 0); break; case Screen.HELP: targetPos = new Vector2(-1920, -1080); break; } moveTween = GetComponent <RectTransform>().DOAnchorPos(targetPos, transitionTime); moveTween.Play(); // Enable/disable scripts mainMenu.SetAsActive(newScreen == Screen.MAINMENU); teamSelect.SetAsActive(newScreen == Screen.TEAMSELECT); helpScreen.SetAsActive(newScreen == Screen.HELP); levelSelect.SetAsActive(newScreen == Screen.LEVELSELECT); }