@@ -57,10 +57,20 @@ public abstract class JCS_Camera
5757 // TopLeft -> BottomLeft
5858 protected Rect mCamRect = new Rect ( ) ;
5959
60- [ Tooltip ( "" ) ]
60+ [ Tooltip ( "Offset the camera position from its' original position. " ) ]
6161 [ SerializeField ]
6262 protected Vector3 mPositionOffset = Vector3 . zero ;
6363
64+ // Record any necessary data, for resize screen event.
65+ protected bool mSceneJustLoad = true ;
66+
67+ // Record down the camera data, orthographic size.
68+ protected float mRecordOrthographicSize = 0.0f ;
69+
70+ // Record down the camera data, filed of view.
71+ protected float mRecordFieldOfView = 0.0f ;
72+
73+
6474 //========================================
6575 // setter / getter
6676 //------------------------------
@@ -89,6 +99,10 @@ protected virtual void Awake()
8999
90100 protected virtual void Start ( )
91101 {
102+ // Record down the camera data.
103+ mRecordOrthographicSize = mCamera . orthographicSize ;
104+ mRecordFieldOfView = mCamera . fieldOfView ;
105+
92106 // add to on screen resize callback.
93107 JCS_ScreenSettings . instance . onScreenResize += OnResizeGame ;
94108 }
@@ -611,6 +625,7 @@ public void SetPosition(Vector3 vec)
611625 SetPosition ( vec . x , vec . y , vec . z ) ;
612626 }
613627
628+
614629 /// <summary>
615630 /// Resize the game if screen size changes.
616631 /// </summary>
@@ -636,6 +651,29 @@ protected virtual void OnResizeGame()
636651 mCamera . orthographicSize *= divRatio ;
637652 mCamera . fieldOfView *= divRatio ;
638653
654+ if ( mSceneJustLoad )
655+ {
656+ float bw = ss . BlackspaceWidth ( ) ;
657+ float bh = ss . BlackspaceHeight ( ) ;
658+
659+ if ( bw > bh )
660+ {
661+ mCamera . orthographicSize = mRecordOrthographicSize ;
662+ mCamera . fieldOfView = mRecordFieldOfView ;
663+ }
664+ else
665+ {
666+ float supposeHeight = ( ( float ) Screen . width * ( float ) ss . STARTING_SCREEN_HEIGHT ) / ( float ) ss . STARTING_SCREEN_WIDTH ;
667+
668+ float heightRatio = ( ( float ) Screen . height / supposeHeight ) ;
669+
670+ mCamera . orthographicSize = heightRatio * mRecordOrthographicSize ;
671+ mCamera . fieldOfView = heightRatio * mRecordFieldOfView ;
672+ }
673+
674+ mSceneJustLoad = false ;
675+ }
676+
639677 /* Store it to screen settings. */
640678 {
641679 ss . ORTHOGRAPHIC_SIZE = mCamera . orthographicSize ;
0 commit comments