1+ using Cinemachine ;
12using System . Collections ;
23using System . Collections . Generic ;
34using UnityEngine ;
@@ -13,9 +14,33 @@ public class SpaceshipHoloTableZoomControl : MonoBehaviour
1314 public UnityEngine . Rendering . Volume m_PostProcessVolume ;
1415 public Vector2 ZoomInOutFov = new Vector2 ( 40 , 75 ) ;
1516 public float dampen = 14f ;
17+ public int MouseRotateButton = 1 ;
1618
1719 float m_CachedValue = 0.0f ;
1820
21+ CinemachineCore . AxisInputDelegate m_AxisDelegateBackup ;
22+
23+ private void OnEnable ( )
24+ {
25+ m_AxisDelegateBackup = CinemachineCore . GetInputAxis ;
26+ CinemachineCore . GetInputAxis = GetInputAxis ;
27+ }
28+
29+ float GetInputAxis ( string axisName )
30+ {
31+ if ( Input . GetMouseButton ( MouseRotateButton ) )
32+ {
33+ return Input . GetAxis ( axisName ) ;
34+ }
35+ else
36+ return 0 ;
37+ }
38+
39+ private void OnDisable ( )
40+ {
41+ CinemachineCore . GetInputAxis = m_AxisDelegateBackup ;
42+ }
43+
1944 // Update is called once per frame
2045 void Update ( )
2146 {
@@ -30,5 +55,16 @@ void Update()
3055 m_PostProcessVolume . weight = value ;
3156 m_Camera . m_Lens . FieldOfView = Mathf . Lerp ( ZoomInOutFov . y , ZoomInOutFov . x , m_CachedValue ) ;
3257 }
58+
59+ if ( Input . GetMouseButton ( MouseRotateButton ) )
60+ {
61+ Cursor . visible = false ;
62+ Cursor . lockState = CursorLockMode . Locked ;
63+ }
64+ else
65+ {
66+ Cursor . visible = true ;
67+ Cursor . lockState = CursorLockMode . None ;
68+ }
3369 }
3470}
0 commit comments