Example #1
0
        /* Functions */

        private void Awake()
        {
            instance = CheckSingleton(instance, this);

            // This will only run once at the time when
            // the application is starts.
            if (!JCS_ApplicationSettings.instance.APPLICATION_STARTS)
            {
                // Calculate standard screen width and screen height.
                {
                    float gcd = JCS_Mathf.GCD(STANDARD_SCREEN_WIDTH, STANDARD_SCREEN_HEIGHT);

                    ASPECT_RATIO_SCREEN_WIDTH  = (int)((float)STANDARD_SCREEN_WIDTH / gcd);
                    ASPECT_RATIO_SCREEN_HEIGHT = (int)((float)STANDARD_SCREEN_HEIGHT / gcd);
                }

                if (RESIZE_TO_ASPECT_WHEN_APP_STARTS)
                {
                    // Force resize screen/window to certain aspect
                    // ratio once.
                    ForceAspectScreenOnce(true);
                }

                if (RESIZE_TO_STANDARD_WHEN_APP_STARTS)
                {
                    // Force resize screen/window to standard
                    // resolution once.
                    ForceStandardScreenOnce(true);
                }

                /*
                 * NOTE(jenchieh): This is really weird, that even we
                 * use 'Screen.SetResolution' function, the 'Screen.width'
                 * and 'Screen.height' will not change immediately.
                 * We just have to get it ourselves in all resize event
                 * function like above these functions.
                 *
                 *   -> ForceAspectScreenOnce
                 *   -> ForceStandardScreenOnce
                 *
                 */
                // Record down the starting screen width and screen height.
                //STARTING_SCREEN_WIDTH = Screen.width;
                //STARTING_SCREEN_HEIGHT = Screen.height;
            }
            else
            {
                // Othereise, check if new scene loaded resize the
                // screen once?
                if (RESIZE_TO_ASPECT_EVERYTIME_SCENE_LOADED)
                {
                    ForceAspectScreenOnce();
                }
            }
        }