コード例 #1
0
        private void AddModMenuButton()
        {
            try
            {
                _rightScreen =
                    ReflectionUtil.GetPrivateField <VRUIViewController>(_mainMenuViewController,
                                                                        "_releaseInfoViewController");
                _rightPos = _rightScreen.gameObject.transform as RectTransform;
                var modMenuButton = CreateButton(_rightPos);
                SetButtonText(ref modMenuButton, "Saber Menu");
                SetButtonIcon(ref modMenuButton, Icons.First(x => x.name == "SingleSaberIcon"));

                if (modMenuButton == null)
                {
                    return;
                }

                // Change button text and add listener
                modMenuButton.onClick.AddListener(delegate
                {
                    try
                    {
                        if (_modMenuController == null)
                        {
                            _modMenuController = CreateViewController <ModMenuMasterViewController>();
                        }
                        try
                        {
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                            throw;
                        }
                        _rightScreen.PresentModalViewController(_modMenuController, null);
                        //DELETE POSSIBLE DIFFICULTY TEXT
                        var modlisttemp = GameObject.FindObjectOfType <ModsListViewController>();
                        if (modlisttemp != null)
                        {
                            var textmeshs = modlisttemp.gameObject.GetComponentsInChildren <TextMeshProUGUI>();


                            foreach (TextMeshProUGUI textmesh in textmeshs)
                            {
                                if (textmesh.rectTransform.parent.name == "DifficultyTableCell(Clone)")
                                {
                                    DestroyImmediate(textmesh.rectTransform.parent.gameObject);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                });
            }

            catch (Exception ex)
            {
            }
        }
コード例 #2
0
        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);
        }