ApplyChange() public method

public ApplyChange ( ) : void
return void
Example #1
0
 void OnEnable()
 {
     if (Application.isPlaying)
     {
         //播放模式下都是通过Stage自带的UIContentScaler实现调整的,所以这里只是把参数传过去
         UIContentScaler scaler = Stage.inst.gameObject.GetComponent <UIContentScaler>();
         if (scaler != this)
         {
             scaler.scaleMode = scaleMode;
             if (scaleMode == ScaleMode.ScaleWithScreenSize)
             {
                 scaler.designResolutionX = designResolutionX;
                 scaler.designResolutionY = designResolutionY;
                 scaler.screenMatchMode   = screenMatchMode;
                 scaler.ignoreOrientation = ignoreOrientation;
             }
             else if (scaleMode == ScaleMode.ConstantPhysicalSize)
             {
                 scaler.fallbackScreenDPI = fallbackScreenDPI;
                 scaler.defaultSpriteDPI  = defaultSpriteDPI;
             }
             else
             {
                 scaler.constantScaleFactor = constantScaleFactor;
             }
             scaler.ApplyChange();
             GRoot.inst.ApplyContentScaleFactor();
         }
     }
     else //Screen width/height is not reliable in OnEnable in editmode
     {
         _changed = true;
     }
 }
Example #2
0
        void OnScreenSizeChanged()
        {
            screenWidth  = Screen.width;
            screenHeight = Screen.height;
            if (screenWidth == 0 || screenHeight == 0)
            {
                return;
            }

            cachedCamera.orthographicSize = screenHeight / 2 * UnitsPerPixel;
            cachedCamera.aspect           = (float)screenWidth / screenHeight;
            cachedTransform.localPosition = new Vector3(cachedCamera.orthographicSize * cachedCamera.aspect, -cachedCamera.orthographicSize);

            if (isMain)
            {
                screenSizeVer++;
                if (Application.isPlaying)
                {
                    Stage.inst.HandleScreenSizeChanged();
                }
                else
                {
                    UIContentScaler scaler = GameObject.FindObjectOfType <UIContentScaler>();
                    if (scaler != null)
                    {
                        scaler.ApplyChange();
                    }
                    else
                    {
                        UIContentScaler.scaleFactor = 1;
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="constantScaleFactor"></param>
        public void SetContentScaleFactor(float constantScaleFactor)
        {
            UIContentScaler scaler = Stage.inst.gameObject.GetComponent <UIContentScaler>();

            scaler.scaleMode           = UIContentScaler.ScaleMode.ConstantPixelSize;
            scaler.constantScaleFactor = constantScaleFactor;
            scaler.ApplyChange();
            ApplyContentScaleFactor();
        }
Example #4
0
        /// <summary>
        /// Set content scale factor.
        /// </summary>
        /// <param name="designResolutionX">Design resolution of x axis.</param>
        /// <param name="designResolutionY">Design resolution of y axis.</param>
        /// <param name="screenMatchMode">Math mode.</param>
        public void SetContentScaleFactor(int designResolutionX, int designResolutionY, UIContentScaler.ScreenMatchMode screenMatchMode)
        {
            UIContentScaler scaler = Stage.inst.gameObject.GetComponent <UIContentScaler>();

            scaler.designResolutionX = designResolutionX;
            scaler.designResolutionY = designResolutionY;
            scaler.scaleMode         = UIContentScaler.ScaleMode.ScaleWithScreenSize;
            scaler.ApplyChange();
            ApplyContentScaleFactor();
        }
Example #5
0
        void OnResolutionChanged(int lw, int lh)
        {
            SetSize(Renderer.ScreenWidth, Renderer.ScreenHeight);
#if CE_5_5
            NGraphics.viewportReverseScale = new Vector2(1, 1);
#else
            NGraphics.viewportReverseScale = new Vector2(800.0f / this.width, 600.0f / this.height);
#endif

            UIContentScaler.ApplyChange();
        }
Example #6
0
        /// <summary>
        /// Set content scale factor.
        /// </summary>
        /// <param name="designResolutionX">Design resolution of x axis.</param>
        /// <param name="designResolutionY">Design resolution of y axis.</param>
        /// <param name="screenMatchMode">Match mode.</param>
        public void SetContentScaleFactor(int designResolutionX, int designResolutionY, UIContentScaler.ScreenMatchMode screenMatchMode)
        {
            UIContentScaler scaler = CentorPivot.This.GetComponent <UIContentScaler>();

            scaler.designResolutionX = designResolutionX;
            scaler.designResolutionY = designResolutionY;
            scaler.scaleMode         = UIContentScaler.ScaleMode.ScaleWithScreenSize;
            scaler.screenMatchMode   = screenMatchMode;
            scaler.ApplyChange();
            ApplyContentScaleFactor();
        }
Example #7
0
        internal void HandleScreenSizeChanged()
        {
            stageWidth  = Screen.width;
            stageHeight = Screen.height;

            UIContentScaler scaler = this.gameObject.GetComponent <UIContentScaler>();

            scaler.ApplyChange();
            GRoot.inst.ApplyContentScaleFactor();

            onStageResized.Call();
        }
 static public int ApplyChange(IntPtr l)
 {
     try {
         FairyGUI.UIContentScaler self = (FairyGUI.UIContentScaler)checkSelf(l);
         self.ApplyChange();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #9
0
        internal void HandleScreenSizeChanged()
        {
            stageWidth  = Screen.width;
            stageHeight = Screen.height;

            this.cachedTransform.localScale = new Vector3(StageCamera.UnitsPerPixel, StageCamera.UnitsPerPixel, StageCamera.UnitsPerPixel);

            UIContentScaler scaler = this.gameObject.GetComponent <UIContentScaler>();

            scaler.ApplyChange();
            GRoot.inst.ApplyContentScaleFactor();

            onStageResized.Call();
        }
Example #10
0
        internal void HandleScreenSizeChanged()
        {
            stageWidth  = Screen.width;
            stageHeight = Screen.height;

            this.cachedTransform.localScale = new Vector3(CameraComponent.UnitsPerPixel, CameraComponent.UnitsPerPixel, CameraComponent.UnitsPerPixel);

            UIContentScaler scaler = CentorPivot.This.GetComponent <UIContentScaler>();

            scaler.ApplyChange();
            GRoot.inst.ApplyContentScaleFactor();

            DispatchEvent("onStageResized", null);
        }
Example #11
0
 static int ApplyChange(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         FairyGUI.UIContentScaler obj = (FairyGUI.UIContentScaler)ToLua.CheckObject(L, 1, typeof(FairyGUI.UIContentScaler));
         obj.ApplyChange();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
        void OnScreenSizeChanged(int newWidth, int newHeight)
        {
            if (newWidth == 0 || newHeight == 0)
            {
                return;
            }

            screenWidth  = newWidth;
            screenHeight = newHeight;

            float upp;

            if (constantSize)
            {
                cachedCamera.orthographicSize = DefaultCameraSize;
                upp = cachedCamera.orthographicSize * 2 / screenHeight;
            }
            else
            {
                upp = 0.02f;
                cachedCamera.orthographicSize = screenHeight / 2 * UnitsPerPixel;
            }
            cachedTransform.localPosition = new Vector3(cachedCamera.orthographicSize * screenWidth / screenHeight, -cachedCamera.orthographicSize);

            if (isMain)
            {
                UnitsPerPixel = upp;
                screenSizeVer++;
                if (Application.isPlaying)
                {
                    Stage.inst.HandleScreenSizeChanged();
                }
                else
                {
                    UIContentScaler scaler = GameObject.FindObjectOfType <UIContentScaler>();
                    if (scaler != null)
                    {
                        scaler.ApplyChange();
                    }
                    else
                    {
                        UIContentScaler.scaleFactor = 1;
                    }
                }
            }
        }
Example #13
0
        void OnResolutionChanged(object sender, EventArgs args)
        {
            SetSize(game.GraphicsDevice.PresentationParameters.BackBufferWidth, game.GraphicsDevice.PresentationParameters.BackBufferHeight);

            UIContentScaler.ApplyChange();
        }