@@ -25,7 +25,7 @@ public enum CursorType
2525 DiagonalLeft ,
2626 DiagonalRight
2727 }
28-
28+
2929 protected readonly WaitUntil _waitForMainCamera = new WaitUntil ( ( ) => Camera . main ) ;
3030 private readonly WaitForSecondsRealtime _waitForSecondsRealtime = new WaitForSecondsRealtime ( 1f ) ;
3131 protected const int OnlyInThirdPerson = 3 ;
@@ -54,7 +54,6 @@ public bool ThirdPerson
5454 }
5555
5656 protected bool _thirdPerson ;
57- public DroneCam . DroneCam droneCam ;
5857 public Vector3 ThirdPersonPos ;
5958 public Vector3 ThirdPersonRot ;
6059 public Vector3 FirstPersonOffset ;
@@ -98,12 +97,12 @@ public bool ThirdPerson
9897 protected bool _isBottom = false , _isLeft = false ;
9998 protected ContextMenuStrip _menuStrip = new ContextMenuStrip ( ) ;
10099 protected List < ToolStripItem > _controlTracker = new List < ToolStripItem > ( ) ;
101-
100+
102101 public static CursorType currentCursor = CursorType . None ;
103102 public static bool wasWithinBorder = false ;
104103 public static bool anyInstanceBusy = false ;
105104 private static bool _contextMenuEnabled = true ;
106-
105+
107106 public virtual void Init ( Config config )
108107 {
109108 DontDestroyOnLoad ( gameObject ) ;
@@ -115,7 +114,7 @@ public virtual void Init(Config config)
115114
116115 StartCoroutine ( DelayedInit ( ) ) ;
117116 }
118-
117+
119118 protected IEnumerator DelayedInit ( )
120119 {
121120 yield return _waitForMainCamera ;
@@ -128,15 +127,15 @@ protected IEnumerator DelayedInit()
128127 Config . ConfigChangedEvent += PluginOnConfigChangedEvent ;
129128
130129 var gameObj = Instantiate ( _mainCamera . gameObject ) ;
131-
130+
132131 gameObj . SetActive ( false ) ;
133132 gameObj . name = "Camera Plus" ;
134133 gameObj . tag = "Untagged" ;
135134 while ( gameObj . transform . childCount > 0 ) DestroyImmediate ( gameObj . transform . GetChild ( 0 ) . gameObject ) ;
136135 DestroyImmediate ( gameObj . GetComponent ( "CameraRenderCallbacksManager" ) ) ;
137136 DestroyImmediate ( gameObj . GetComponent ( "AudioListener" ) ) ;
138137 DestroyImmediate ( gameObj . GetComponent ( "MeshCollider" ) ) ;
139-
138+
140139 _cam = gameObj . GetComponent < Camera > ( ) ;
141140 _cam . stereoTargetEye = StereoTargetEyeMask . None ;
142141 _cam . enabled = true ;
@@ -178,7 +177,7 @@ protected IEnumerator DelayedInit()
178177 _quad . transform . localEulerAngles = new Vector3 ( 0 , 180 , 0 ) ;
179178 _quad . transform . localScale = new Vector3 ( _cam . aspect , 1 , 1 ) ;
180179 _cameraPreviewQuad = _quad ;
181-
180+
182181 ReadConfig ( ) ;
183182
184183 if ( ThirdPerson )
@@ -191,19 +190,6 @@ protected IEnumerator DelayedInit()
191190
192191 _cameraCube . position = ThirdPersonPos ;
193192 _cameraCube . eulerAngles = ThirdPersonRot ;
194-
195- if ( Config . droneCam && droneCam == null )
196- {
197- try
198- {
199- droneCam = gameObject . AddComponent < DroneCam . DroneCam > ( ) ;
200- droneCam . SetupCam ( Path . GetFileName ( Config . FilePath ) ) ;
201- }
202- catch ( Exception e )
203- {
204- Console . WriteLine ( "CamPlusDroneErr:\n {0} {1} {2}" , e . GetType ( ) . ToString ( ) , e . Message , e . StackTrace ) ;
205- }
206- }
207193 }
208194
209195 // Add our camera movement script if the movement script path is set
@@ -221,7 +207,7 @@ protected IEnumerator DelayedInit()
221207 SceneManager_activeSceneChanged ( new Scene ( ) , new Scene ( ) ) ;
222208 Plugin . Log ( $ "Camera \" { Path . GetFileName ( Config . FilePath ) } \" successfully initialized!\" ") ;
223209 }
224-
210+
225211 protected virtual void OnDestroy ( )
226212 {
227213 Config . ConfigChangedEvent -= PluginOnConfigChangedEvent ;
@@ -257,7 +243,7 @@ protected virtual void ReadConfig()
257243 transform . rotation = _mainCamera . transform . rotation ;
258244
259245 }
260- else if ( ! Config . droneCam )
246+ else
261247 {
262248 ThirdPersonPos = Config . Position ;
263249 ThirdPersonRot = Config . Rotation ;
@@ -299,7 +285,7 @@ protected virtual void CreateScreenRenderTexture()
299285 return ;
300286 }
301287
302- if ( Config . fitToCanvas )
288+ if ( Config . fitToCanvas )
303289 {
304290 Config . screenPosX = 0 ;
305291 Config . screenPosY = 0 ;
@@ -331,12 +317,12 @@ protected virtual void CreateScreenRenderTexture()
331317 _prevScreenPosY = Config . screenPosY ;
332318 } ) ;
333319 }
334-
320+
335321 public virtual void SceneManager_activeSceneChanged ( Scene from , Scene to )
336322 {
337323 StartCoroutine ( GetMainCamera ( ) ) ;
338324 var vrPointers = to . name == "GameCore" ? Resources . FindObjectsOfTypeAll < VRPointer > ( ) : Resources . FindObjectsOfTypeAll < VRPointer > ( ) ;
339- if ( vrPointers . Count ( ) == 0 )
325+ if ( vrPointers . Count ( ) == 0 )
340326 {
341327 Plugin . Log ( "Failed to get VRPointer!" ) ;
342328 return ;
@@ -353,7 +339,7 @@ public virtual void SceneManager_activeSceneChanged(Scene from, Scene to)
353339
354340 protected void OnApplicationFocus ( bool hasFocus )
355341 {
356- if ( ! hasFocus && GetActiveWindow ( ) == IntPtr . Zero )
342+ if ( ! hasFocus && GetActiveWindow ( ) == IntPtr . Zero )
357343 CloseContextMenu ( ) ;
358344 }
359345
@@ -365,26 +351,22 @@ protected virtual void Update()
365351 if ( Input . GetKeyDown ( KeyCode . F1 ) )
366352 {
367353 ThirdPerson = ! ThirdPerson ;
368- if ( ThirdPerson )
354+ if ( ! ThirdPerson )
369355 {
370356 transform . position = _mainCamera . transform . position ;
371357 transform . rotation = _mainCamera . transform . rotation ;
372358 FirstPersonOffset = Config . FirstPersonPositionOffset ;
373359 }
360+ else
361+ {
362+ ThirdPersonPos = Config . Position ;
363+ ThirdPersonRot = Config . Rotation ;
364+ }
374365
375366 Config . thirdPerson = ThirdPerson ;
376367 Config . Save ( ) ;
377368 }
378369 }
379-
380- if ( droneCam != null )
381- {
382- droneCam . Update ( ) ;
383- }
384- else
385- {
386-
387- }
388370 HandleMouseEvents ( ) ;
389371 }
390372
@@ -394,30 +376,20 @@ protected virtual void LateUpdate()
394376 {
395377 var camera = _mainCamera . transform ;
396378
397- if ( Config . droneCam && ThirdPerson )
398- {
399- transform . position = Vector3 . Lerp ( transform . position , droneCam . smoothingTarget . position ,
400- Config . positionSmooth * Time . unscaledDeltaTime ) ;
401-
402- transform . rotation = Quaternion . Slerp ( transform . rotation , droneCam . smoothingTarget . rotation ,
403- Config . rotationSmooth * Time . unscaledDeltaTime ) ;
404- }
405- else if ( ! Config . droneCam && ThirdPerson )
379+ if ( ThirdPerson )
406380 {
407381 transform . position = ThirdPersonPos ;
408382 transform . eulerAngles = ThirdPersonRot ;
409383 _cameraCube . position = ThirdPersonPos ;
410384 _cameraCube . eulerAngles = ThirdPersonRot ;
411385 return ;
412386 }
413- else
414- {
415- transform . position = Vector3 . Lerp ( transform . position , camera . position + FirstPersonOffset ,
416- Config . positionSmooth * Time . unscaledDeltaTime ) ;
417387
418- transform . rotation = Quaternion . Slerp ( transform . rotation , camera . rotation ,
419- Config . rotationSmooth * Time . unscaledDeltaTime ) ;
420- }
388+ transform . position = Vector3 . Lerp ( transform . position , camera . position + FirstPersonOffset ,
389+ Config . positionSmooth * Time . unscaledDeltaTime ) ;
390+
391+ transform . rotation = Quaternion . Slerp ( transform . rotation , camera . rotation ,
392+ Config . rotationSmooth * Time . unscaledDeltaTime ) ;
421393 }
422394 catch { }
423395 }
@@ -461,17 +433,12 @@ protected virtual void SetFOV()
461433
462434 protected virtual void SetCullingMask ( )
463435 {
464- if ( Config . transparentWalls )
436+ if ( Config . transparentWalls )
465437 _cam . cullingMask &= ~ ( 1 << TransparentWallsPatch . WallLayerMask ) ;
466438 else
467439 _cam . cullingMask |= ( 1 << TransparentWallsPatch . WallLayerMask ) ;
468440 }
469441
470- public void LookAt ( Transform target )
471- {
472- transform . LookAt ( target ) ;
473- }
474-
475442 public bool IsWithinRenderArea ( Vector2 mousePos , Config c )
476443 {
477444 if ( mousePos . x < c . screenPosX ) return false ;
@@ -493,13 +460,13 @@ public bool IsTopmostRenderAreaAtPos(Vector2 mousePos)
493460 return false ;
494461 }
495462
496- if ( c . Config . layer == Config . layer &&
463+ if ( c . Config . layer == Config . layer &&
497464 c . Instance . _lastRenderUpdate > _lastRenderUpdate )
498465 {
499466 return false ;
500467 }
501468
502- if ( c . Instance . _mouseHeld && ( c . Instance . _isMoving ||
469+ if ( c . Instance . _mouseHeld && ( c . Instance . _isMoving ||
503470 c . Instance . _isResizing || c . Instance . _contextMenuOpen ) )
504471 {
505472 return false ;
@@ -535,7 +502,7 @@ protected void CloseContextMenu()
535502 }
536503 _contextMenuOpen = false ;
537504 }
538-
505+
539506 public static void SetCursor ( CursorType type )
540507 {
541508 if ( type != currentCursor )
@@ -556,7 +523,7 @@ public static void SetCursor(CursorType type)
556523 texture = Utils . LoadTextureFromResources ( "CameraPlus.Resources.Resize_DiagLeft.png" ) ;
557524 break ;
558525 }
559- UnityEngine . Cursor . SetCursor ( texture , texture ? new Vector2 ( texture . width / 2 , texture . height / 2 ) : new Vector2 ( 0 , 0 ) , CursorMode . Auto ) ;
526+ UnityEngine . Cursor . SetCursor ( texture , texture ? new Vector2 ( texture . width / 2 , texture . height / 2 ) : new Vector2 ( 0 , 0 ) , CursorMode . Auto ) ;
560527 currentCursor = type ;
561528 }
562529 }
@@ -629,7 +596,7 @@ protected void HandleMouseEvents()
629596 {
630597 _initialOffset . x = currentMouseOffsetX ;
631598 _initialOffset . y = currentMouseOffsetY ;
632-
599+
633600 _lastScreenPos = Config . ScreenPosition ;
634601 _lastGrabPos = new Vector2 ( mousePos . x , mousePos . y ) ;
635602
@@ -667,7 +634,7 @@ protected void HandleMouseEvents()
667634 Config . screenHeight = Mathf . Clamp ( Config . screenHeight , 100 , Screen . height ) ;
668635 Config . screenPosX = Mathf . Clamp ( Config . screenPosX , 0 , Screen . width - Config . screenWidth ) ;
669636 Config . screenPosY = Mathf . Clamp ( Config . screenPosY , 0 , Screen . height - Config . screenHeight ) ;
670-
637+
671638 CreateScreenRenderTexture ( ) ;
672639 }
673640 else if ( holdingRightClick && _contextMenuEnabled )
@@ -758,7 +725,6 @@ void DisplayContextMenu()
758725 CloseContextMenu ( ) ;
759726 Config . Save ( ) ;
760727 } ) ;
761-
762728 if ( Config . thirdPerson )
763729 {
764730 // Hides/unhides the third person camera that appears when a camera is in third person mode
@@ -782,23 +748,6 @@ void DisplayContextMenu()
782748 Config . Save ( ) ;
783749 CloseContextMenu ( ) ;
784750 } ) ;
785-
786- _menuStrip . Items . Add ( Config . droneCam ? "Disable DroneCam" : "Ënable Drone Cam" , null , ( p1 , p2 ) =>
787- {
788- if ( Config . droneCam && droneCam != null )
789- {
790- Config . droneCam = false ;
791- droneCam . CleanUp ( ) ;
792- Destroy ( droneCam ) ;
793- } else
794- {
795- Config . droneCam = true ;
796- droneCam = gameObject . AddComponent < DroneCam . DroneCam > ( ) ;
797- droneCam . SetupCam ( Path . GetFileName ( Config . FilePath ) ) ;
798- }
799- Config . droneCam = false ;
800- Config . Save ( ) ;
801- } ) ;
802751 }
803752 _menuStrip . Items . Add ( new ToolStripSeparator ( ) ) ;
804753
@@ -865,7 +814,7 @@ void DisplayContextMenu()
865814 Config . Save ( ) ;
866815 } ;
867816 _layoutMenu . DropDownItems . Add ( _renderScale ) ;
868-
817+
869818
870819 // Sets the size of the current cameras pixelrect
871820 _layoutMenu . DropDownItems . Add ( new ToolStripLabel ( "Size" ) ) ;
@@ -923,7 +872,7 @@ void DisplayContextMenu()
923872 } ;
924873 _layoutMenu . DropDownItems . Add ( _yBox ) ;
925874
926-
875+
927876 // Fit to canvas checkbox
928877 var _fitToCanvasBox = new ToolStripCheckBox ( "Fit to Canvas" ) ;
929878 _controlTracker . Add ( _fitToCanvasBox ) ;
@@ -965,8 +914,7 @@ void DisplayContextMenu()
965914 CameraMovement . CreateExampleScript ( ) ;
966915 ofd . InitialDirectory = path ;
967916 ofd . Title = "Select a script" ;
968- ofd . FileOk += ( sender , e ) =>
969- {
917+ ofd . FileOk += ( sender , e ) => {
970918 string file = ( ( OpenFileDialog ) sender ) . FileName ;
971919 if ( File . Exists ( file ) )
972920 {
@@ -990,7 +938,7 @@ void DisplayContextMenu()
990938 } ) ;
991939 _addSongMovement . Enabled = Config . movementScriptPath != "SongMovementScript" ;
992940 _scriptsMenu . DropDownItems . Add ( _addMenu ) ;
993-
941+
994942 // Remove menu
995943 var _removeMenu = new ToolStripMenuItem ( "Remove" ) ;
996944 _controlTracker . Add ( _removeMenu ) ;
0 commit comments