示例#1
0
 private void Globals_PropertyChanged(object source, string propertyName)
 {
     if (propertyName == nameof(Models.Globals.IsPortrait))
     {
         if (!ReferenceResolutionProperty.IsUndefined(this))
         {
             if (AdjustToScreenOrientation == AdjustToScreenOrientation.SwapResolutionAndMatchInPortrait)
             {
                 ReferenceResolution = Models.Globals.IsPortrait ? new Vector2(_defaultReferenceResolution.y, _defaultReferenceResolution.x) : _defaultReferenceResolution;
                 if (ScreenMatchMode == CanvasScaler.ScreenMatchMode.MatchWidthOrHeight)
                 {
                     MatchWidthOrHeight = Models.Globals.IsPortrait ? 1 - _defaultMatch : _defaultMatch;
                 }
             }
             else if (AdjustToScreenOrientation == AdjustToScreenOrientation.SwapResolutionAndMatchInLandscape)
             {
                 ReferenceResolution = Models.Globals.IsLandscape ? new Vector2(_defaultReferenceResolution.y, _defaultReferenceResolution.x) : _defaultReferenceResolution;
                 if (ScreenMatchMode == CanvasScaler.ScreenMatchMode.MatchWidthOrHeight)
                 {
                     MatchWidthOrHeight = Models.Globals.IsLandscape ? 1 - _defaultMatch : _defaultMatch;
                 }
             }
         }
     }
 }
示例#2
0
        protected override void AfterLoad()
        {
            base.AfterLoad();

            if (AdjustToScreenOrientation != AdjustToScreenOrientation.Never)
            {
                if (!ReferenceResolutionProperty.IsUndefined(this))
                {
                    _defaultReferenceResolution = ReferenceResolution;
                    _defaultMatch = MatchWidthOrHeight;
                }

                Models.Globals.PropertyChanged -= Globals_PropertyChanged;
                Models.Globals.PropertyChanged += Globals_PropertyChanged;
            }
        }