Esempio n. 1
0
        public static bool RemoveCamera(CameraPlusBehaviour instance, bool delete = true)
        {
            try
            {
                if (Plugin.Instance.Cameras.TryRemove(Plugin.Instance.Cameras.Where(c => c.Value.Instance == instance && c.Key != "cameraplus.cfg")?.First().Key, out var removedEntry))
                {
                    if (delete)
                    {
                        if (File.Exists(removedEntry.Config.FilePath))
                        {
                            File.Delete(removedEntry.Config.FilePath);
                        }
                    }

                    GL.Clear(false, true, Color.black, 0);
                    GameObject.Destroy(removedEntry.Instance.gameObject);
                    return(true);
                }
            }
            catch (Exception)
            {
                Plugin.Log("Can't remove cam!");
            }
            return(false);
        }
Esempio n. 2
0
        private IEnumerator DelayedOnSceneLoaded(Scene scene)
        {
            yield return(_waitForSecondsRealtime);

            if (scene.buildIndex < 1)
            {
                yield break;
            }
            if (_cameraPlus != null)
            {
                Object.Destroy(_cameraPlus.gameObject);
            }

            var mainCamera = Camera.main;

            if (mainCamera == null)
            {
                yield break;
            }

            var gameObj = new GameObject("CameraPlus");

            _cameraPlus = gameObj.AddComponent <CameraPlusBehaviour>();
            _cameraPlus.Init(mainCamera);
        }
 internal void WebCameraCalibration(CameraPlusBehaviour camplus)
 {
     _webCamCal = new GameObject("WebCamCalScreen").AddComponent <WebCamCalibrator>();
     _webCamCal.transform.SetParent(this.transform);
     _webCamCal.Init();
     _webCamCal.AddCalibrationScreen(camplus, Camera.main);
 }
Esempio n. 4
0
 public virtual void Init(CameraPlusBehaviour cameraPlus, Transform cameraCube)
 {
     _cameraPlus = cameraPlus;
     _cameraCube = cameraCube;
     _realPos    = Plugin.Instance.Config.Position;
     _realRot    = Quaternion.Euler(Plugin.Instance.Config.Rotation);
     _vrPointer  = GetComponent <VRPointer>();
 }
Esempio n. 5
0
        public CameraPlusInstance(string configPath)
        {
            Config = new Config(configPath);

            var gameObj = new GameObject($"CamPlus_{Path.GetFileName(configPath)}");

            Instance = gameObj.AddComponent <CameraPlusBehaviour>();
            Instance.Init(Config);
        }
Esempio n. 6
0
 public void EnableMenu(Vector2 mousePos, CameraPlusBehaviour parentBehaviour)
 {
     this.enabled = true;
     //       Console.WriteLine("Enable Menu");
     mousePosition        = mousePos;
     showMenu             = true;
     this.parentBehaviour = parentBehaviour;
     layoutMode           = false;
 }
Esempio n. 7
0
 public void OnFixedUpdate()
 {
     // Fix the cursor when the user resizes the main camera to be smaller than the canvas size and they hover over the black portion of the canvas
     if (CameraPlusBehaviour.currentCursor != CameraPlusBehaviour.CursorType.None && !CameraPlusBehaviour.anyInstanceBusy &&
         CameraPlusBehaviour.wasWithinBorder && CameraPlusBehaviour.GetTopmostInstanceAtCursorPos() == null)
     {
         CameraPlusBehaviour.SetCursor(CameraPlusBehaviour.CursorType.None);
         CameraPlusBehaviour.wasWithinBorder = false;
     }
 }
Esempio n. 8
0
 public override bool Init(CameraPlusBehaviour cameraPlus)
 {
     if (Utils.IsModInstalled("Song Loader Plugin"))
     {
         _cameraPlus = cameraPlus;
         Plugin.Instance.ActiveSceneChanged += SceneManager_activeSceneChanged;
         return(true);
     }
     return(false);
 }
Esempio n. 9
0
 public virtual bool Init(CameraPlusBehaviour cameraPlus)
 {
     if (_audioTimeSyncController == null)
     {
         _audioTimeSyncController = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
     }
     _cameraPlus = cameraPlus;
     Plugin.Instance.ActiveSceneChanged += OnActiveSceneChanged;
     return(LoadCameraData(cameraPlus.Config.movementScriptPath));
 }
Esempio n. 10
0
 public override bool Init(CameraPlusBehaviour cameraPlus)
 {
     if (Utils.IsModInstalled("BS_Utils"))
     {
         _cameraPlus = cameraPlus;
         Plugin.Instance.ActiveSceneChanged += OnActiveSceneChanged;
         return(true);
     }
     return(false);
 }
Esempio n. 11
0
        public virtual bool Init(CameraPlusBehaviour cameraPlus, bool useSongSpecificScript)
        {
            _cameraPlus = cameraPlus;
            Plugin.Instance.ActiveSceneChanged += OnActiveSceneChanged;

            if (useSongSpecificScript && File.Exists(Path.Combine(CustomPreviewBeatmapLevelPatch.customLevelPath, "SongScript.json")))
            {
                Logger.Log($"{Path.Combine(CustomPreviewBeatmapLevelPatch.customLevelPath, "SongScript.json")}", LogLevel.Notice);
                return(LoadCameraData(Path.Combine(CustomPreviewBeatmapLevelPatch.customLevelPath, "SongScript.json")));
            }
            else
            {
                return(LoadCameraData(cameraPlus.Config.movementScriptPath));
            }
        }
Esempio n. 12
0
        public void EnableMenu(Vector2 mousePos, CameraPlusBehaviour parentBehaviour)
        {
            this.enabled         = true;
            mousePosition        = mousePos;
            showMenu             = true;
            this.parentBehaviour = parentBehaviour;
            MenuMode             = 0;
            scriptName           = null;
            scriptPage           = 0;

            if (this.parentBehaviour.Config.LockScreen)
            {
                texture = Utils.LoadTextureFromResources("CameraPlus.Resources.Lock.png");
            }
            else
            {
                texture = Utils.LoadTextureFromResources("CameraPlus.Resources.UnLock.png");
            }
        }
Esempio n. 13
0
        public virtual bool Init(CameraPlusBehaviour cameraPlus, bool useSongSpecificScript)
        {
            if (_audioTimeSyncController == null)
            {
                _audioTimeSyncController = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
            }

            _cameraPlus = cameraPlus;
            Plugin.Instance.ActiveSceneChanged += OnActiveSceneChanged;

            if (useSongSpecificScript && File.Exists(Path.Combine(CustomPreviewBeatmapLevelPatch.customLevelPath, "SongScript.json")))
            {
                Logger.Log($"{Path.Combine(CustomPreviewBeatmapLevelPatch.customLevelPath, "SongScript.json")}", LogLevel.Notice);
                return(LoadCameraData(Path.Combine(CustomPreviewBeatmapLevelPatch.customLevelPath, "SongScript.json")));
            }
            else
            {
                return(LoadCameraData(cameraPlus.Config.movementScriptPath));
            }
        }
Esempio n. 14
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            if (scene.buildIndex < 1)
            {
                return;
            }
            if (_cameraPlus != null)
            {
                Object.Destroy(_cameraPlus.gameObject);
            }
            var mainCamera = Object.FindObjectsOfType <Camera>().FirstOrDefault(x => x.CompareTag("MainCamera"));

            if (mainCamera == null)
            {
                return;
            }
            var gameObj = new GameObject("CameraPlus");

            CameraPlusBehaviour.MainCamera = mainCamera;
            _cameraPlus = gameObj.AddComponent <CameraPlusBehaviour>();
        }
Esempio n. 15
0
        public static bool RemoveCamera(CameraPlusBehaviour instance, bool delete = true)
        {
            try
            {
                if (Path.GetFileName(instance.Config.FilePath) != $"{Plugin.MainCamera}.cfg")
                {
                    if (Plugin.Instance.Cameras.TryRemove(Plugin.Instance.Cameras.Where(c => c.Value.Instance == instance && c.Key != $"{Plugin.MainCamera}.cfg")?.First().Key, out var removedEntry))
                    {
                        if (delete)
                        {
                            if (File.Exists(removedEntry.Config.FilePath))
                            {
                                File.Delete(removedEntry.Config.FilePath);
                            }
                        }

                        GL.Clear(false, true, Color.black, 0);
                        GameObject.Destroy(removedEntry.Instance.gameObject);
                        return(true);
                    }
                }
                else
                {
                    Logger.Log("One does not simply remove the main camera!", LogLevel.Warning);
                }
            }
            catch (Exception ex)
            {
                string msg
                    = ((instance != null && instance.Config != null && instance.Config.FilePath != null)
                    ? $"Could not remove camera with configuration: '{Path.GetFileName(instance.Config.FilePath)}'."
                    : $"Could not remove camera.");

                Logger.Log($"{msg} CameraUtilities.RemoveCamera() threw an exception:" +
                           $" {ex.Message}\n{ex.StackTrace}", LogLevel.Error);
            }
            return(false);
        }
Esempio n. 16
0
 public virtual bool Init(CameraPlusBehaviour cameraPlus)
 {
     _cameraPlus = cameraPlus;
     Plugin.Instance.ActiveSceneChanged += SceneManager_activeSceneChanged;
     return(LoadCameraData(cameraPlus.Config.movementScriptPath));
 }
Esempio n. 17
0
 public override bool Init(CameraPlusBehaviour cameraPlus)
 {
     _cameraPlus = cameraPlus;
     Plugin.Instance.ActiveSceneChanged += OnActiveSceneChanged;
     return(true);
 }