コード例 #1
0
        public System.Collections.IEnumerator DelayedUI()
        {
            yield return(new WaitForSeconds(0.5f));

            try
            {
                Console.WriteLine("Atemmpting Practice Plugin UI");
                var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("Canvas");

                if (canvas == null)
                {
                    Console.WriteLine("Canvas Null");
                }
                _uiElementsCreator = canvas.gameObject.AddComponent <UIElementsCreator>();
                _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent;
                _uiElementsCreator.Init();
                TimeScale = TimeScale;

                var bg = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("UI").transform.Find("BG");
                //      bg.transform.localScale = new Vector3(bg.transform.localScale.x * 1f, bg.transform.localScale.y * 1.2f, bg.transform.localScale.z * 1f);
                bg.transform.localPosition = new Vector3(bg.transform.localPosition.x, bg.transform.localPosition.y - 0.35f, bg.transform.localPosition.z);
                var pauseMenu = GameObject.Find("PauseMenu");
                pauseMenu.transform.localPosition = new Vector3(pauseMenu.transform.localPosition.x, pauseMenu.transform.localPosition.y + 0.175f, pauseMenu.transform.localPosition.z);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #2
0
ファイル: Plugin.cs プロジェクト: Kylemc1413/PracticePlugin
        public System.Collections.IEnumerator DelayedSetup()
        {
            yield return(new WaitForSeconds(0.1f));

            try
            {
                if (_spawnController == null)
                {
                    _spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().LastOrDefault();
                }
                Console.WriteLine("Atemmpting Practice Plugin UI");

                var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("MenuWrapper").transform.Find("Canvas");

                if (canvas == null)
                {
                    Console.WriteLine("Canvas Null");
                }


                GameObject uiObj = new GameObject("PracticePlugin Seeker UI", typeof(RectTransform));

                (uiObj.transform as RectTransform).anchorMin = new Vector2(0, 0);
                (uiObj.transform as RectTransform).anchorMax = new Vector2(1, 1);
                (uiObj.transform as RectTransform).sizeDelta = new Vector2(0, 0);

                _uiElementsCreator = uiObj.AddComponent <UIElementsCreator>();
                var practiceUI = new GameObject("PracticePlugin Adjustment UI").AddComponent <PracticeUI>();
                UIElementsCreator.practiceUI = practiceUI;
                BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, practiceUI);
                _uiElementsCreator.Init();

                uiObj.transform.SetParent(canvas, false);

                uiObj.transform.localScale    = new Vector3(1, 1, 1);
                uiObj.transform.localPosition = new Vector3(0f, -3f, 0f);

                new GameObject("Practice Plugin Behavior").AddComponent <Behavior>();
                if (startWithFullEnergy)
                {
                    GameEnergyCounter energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                    if (energyCounter != null)
                    {
                        energyCounter.ProcessEnergyChange(1 - energyCounter.energy);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #3
0
        private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            if (scene.name == MenuSceneName)
            {
                if (_resetNoFail)
                {
                    var resultsViewController =
                        Resources.FindObjectsOfTypeAll <ResultsViewController>().FirstOrDefault();
                    if (resultsViewController != null)
                    {
                        resultsViewController.continueButtonPressedEvent +=
                            ResultsViewControllerOnContinueButtonPressedEvent;
                    }
                }

                if (SettingsObject != null)
                {
                    return;
                }

                var volumeSettings = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();

                if (volumeSettings == null)
                {
                    return;
                }

                volumeSettings.gameObject.SetActive(false);
                SettingsObject = Object.Instantiate(volumeSettings.gameObject);
                SettingsObject.SetActive(false);
                volumeSettings.gameObject.SetActive(true);

                if (SettingsObject == null)
                {
                    return;
                }

                var volume = SettingsObject.GetComponent <VolumeSettingsController>();
                ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController),
                                             typeof(SpeedSettingsController), SettingsObject);
                Object.DestroyImmediate(volume);

                SettingsObject.GetComponentInChildren <TMP_Text>().text = "SPEED";
                Object.DontDestroyOnLoad(SettingsObject);
            }
            else if (scene.name == GameSceneName)
            {
                CustomEffectPoolsInstaller customEffectPoolsInstaller = null;
                var effectPoolsInstaller = Resources.FindObjectsOfTypeAll <EffectPoolsInstaller>().FirstOrDefault();
                if (effectPoolsInstaller != null)
                {
                    customEffectPoolsInstaller = (CustomEffectPoolsInstaller)ReflectionUtil.CopyComponent(effectPoolsInstaller,
                                                                                                          typeof(EffectPoolsInstaller), typeof(CustomEffectPoolsInstaller), effectPoolsInstaller.gameObject);
                }

                SceneContext          sceneContext          = null;
                SceneDecoratorContext sceneDecoratorContext = null;

                foreach (var gameObject in scene.GetRootGameObjects())
                {
                    if (sceneContext == null)
                    {
                        sceneContext = gameObject.GetComponentInChildren <SceneContext>(true);
                    }
                }

                foreach (var gameObject in SceneManager.GetSceneByName(ContextSceneName).GetRootGameObjects())
                {
                    if (sceneDecoratorContext == null)
                    {
                        sceneDecoratorContext = gameObject.GetComponentInChildren <SceneDecoratorContext>(true);
                    }
                }


                if (sceneContext != null && sceneDecoratorContext != null)
                {
                    var prop           = typeof(Context).GetField("_installers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                    var installersList = (List <MonoInstaller>)prop.GetValue(sceneDecoratorContext);
                    installersList.Remove(effectPoolsInstaller);
                    Object.DestroyImmediate(effectPoolsInstaller);
                    installersList.Add(customEffectPoolsInstaller);
                }

                if (_mainGameSceneSetupData == null)
                {
                    _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                    if (_mainGameSceneSetupData == null)
                    {
                        return;
                    }
                    _mainGameSceneSetupData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent;
                }

                if (_lastLevelId != _mainGameSceneSetupData.difficultyLevel.level.levelID &&
                    !string.IsNullOrEmpty(_lastLevelId))
                {
                    PlayingNewSong      = true;
                    HasTimeScaleChanged = false;
                    TimeScale           = 1;
                    _lastLevelId        = _mainGameSceneSetupData.difficultyLevel.level.levelID;
                }
                else
                {
                    PlayingNewSong = false;
                }

                if (IsEqualToOne(TimeScale))
                {
                    HasTimeScaleChanged = false;
                }

                _lastLevelId = _mainGameSceneSetupData.difficultyLevel.level.levelID;

                AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                _songAudio    = AudioTimeSync.GetPrivateField <AudioSource>("_audioSource");
                NoFail        = !_mainGameSceneSetupData.gameplayOptions.validForScoreUse;

                if (!NoFail)
                {
                    TimeScale = Mathf.Clamp(TimeScale, 1, MaxSize);
                }

                var canvas = Resources.FindObjectsOfTypeAll <HorizontalLayoutGroup>()
                             .FirstOrDefault(x => x.name == "Buttons")
                             ?.transform.parent;

                if (canvas == null)
                {
                    return;
                }

                _uiElementsCreator = canvas.gameObject.AddComponent <UIElementsCreator>();
                _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent;
                _uiElementsCreator.Init();
                TimeScale = TimeScale;
            }
        }