void Awake() { Instance = this; //DontDestroyOnLoad(gameObject); foreach (Sprite sprite in Resources.FindObjectsOfTypeAll <Sprite>()) { Icons.Add(sprite); } try { // Get necessary button instances and main menu VC var allButtons = Resources.FindObjectsOfTypeAll <Button>(); _buttonInstance = Resources.FindObjectsOfTypeAll <Button>().First(x => x.name == "QuitButton"); _cogWheelButtonInstance = allButtons.FirstOrDefault(x => x.name == "SettingsButton"); _downArrowBtn = allButtons.First(x => x.name == "PageDownButton"); _upArrowBtn = allButtons.First(x => x.name == "PageUpButton"); _backButtonInstance = allButtons.First(x => x.name == "BackArrowButton"); _mainMenuViewController = Resources.FindObjectsOfTypeAll <MainMenuViewController>().First(); _menuMasterViewController = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First(); _mainMenuRectTransform = (RectTransform)_buttonInstance.transform.parent; AddModMenuButton(); } catch (Exception ex) { } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { // Find ModMenuUi object and create back button on screen _modMenuUi = FindObjectOfType <ModMenuUi>(); try { _backButton = _modMenuUi.CreateBackButton(rectTransform); (_backButton.transform as RectTransform).anchorMin = new Vector2(0, 0); (_backButton.transform as RectTransform).anchorMin = new Vector2(0, 0); (_backButton.transform as RectTransform).anchoredPosition = new Vector2(0, 0.5f); _backButton.onClick.AddListener(delegate() { DismissModalViewController(null, false); }); if (ModsListViewController == null) { ModsListViewController = _modMenuUi.CreateViewController <ModsListViewController>(); } ModsListViewController.rectTransform.anchorMin = new Vector2(0.3f, 0f); ModsListViewController.rectTransform.anchorMax = new Vector2(0.7f, 1f); PushViewController(ModsListViewController, true); Console.WriteLine("View Controller activated"); //base.DidActivate(); } catch (Exception ex) { } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { Console.WriteLine("checkpoint 1"); previewparent = Instantiate(new GameObject("preview parent")); previewparent.transform.position = new Vector3(2.5f, 1, 0.3f); previewparent.transform.Rotate(new Vector3(0, -30, 0)); _modMenuUi = FindObjectOfType <ModMenuUi>(); _parentViewController = transform.parent.GetComponent <ModMenuMasterViewController>(); Console.WriteLine("checkpoint 2"); try { if (_pageDownButton == null) { try { _pageDownButton = _modMenuUi.CreateButton(rectTransform, "PageDownButton"); Console.WriteLine("checkpoint 3"); ((RectTransform)_pageDownButton.transform).anchorMin = new Vector2(0.5f, 0f); ((RectTransform)_pageDownButton.transform).anchorMax = new Vector2(0.5f, 0f); ((RectTransform)_pageDownButton.transform).anchoredPosition = new Vector2(0f, 10f); _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { _modsTableView.PageScrollDown(); }); } catch (Exception e) { Console.WriteLine(e); throw; } } if (_pageUpButton == null) { try { Console.WriteLine("checkpoint 4"); _pageUpButton = _modMenuUi.CreateButton(rectTransform, "PageUpButton"); ((RectTransform)_pageUpButton.transform).anchorMin = new Vector2(0.5f, 1f); ((RectTransform)_pageUpButton.transform).anchorMax = new Vector2(0.5f, 1f); ((RectTransform)_pageUpButton.transform).anchoredPosition = new Vector2(0f, -14f); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _modsTableView.PageScrollUp(); }); } catch (Exception e) { Console.WriteLine(e); throw; } } } catch (Exception ex) { Console.WriteLine(ex); } _songListTableCellInstance = Resources.FindObjectsOfTypeAll <StandardLevelListTableCell>().First(x => (x.name == "StandardLevelListTableCell")); LoadMods(); base.DidActivate(true, ActivationType.AddedToHierarchy); }