Esempio n. 1
0
        public override void EditorSave()
        {
            base.EditorSave();
            UIDeviceType deviceType = UILayoutManager.DeviceType;

            if (deviceType != UIDeviceType.Phone)
            {
                if (deviceType == UIDeviceType.Tablet)
                {
                    switch (UILayoutManager.Orientation)
                    {
                    case UIDeviceOrientation.Portrait:
                    case UIDeviceOrientation.PortraitUpsideDown:
                        if (this.tabletPortrait == null)
                        {
                            this.tabletPortrait = new UIRectPositionData();
                        }
                        this.tabletPortrait = UIRectPositionData.FromTransform(base.transform);
                        break;

                    case UIDeviceOrientation.LandscapeRight:
                    case UIDeviceOrientation.LandscapeLeft:
                        if (this.tabletLandscape == null)
                        {
                            this.tabletLandscape = new UIRectPositionData();
                        }
                        this.tabletLandscape = UIRectPositionData.FromTransform(base.transform);
                        break;
                    }
                }
            }
            else
            {
                switch (UILayoutManager.Orientation)
                {
                case UIDeviceOrientation.Portrait:
                case UIDeviceOrientation.PortraitUpsideDown:
                    if (this.phonePortrait == null)
                    {
                        this.phonePortrait = new UIRectPositionData();
                    }
                    this.phonePortrait = UIRectPositionData.FromTransform(base.transform);
                    break;

                case UIDeviceOrientation.LandscapeRight:
                case UIDeviceOrientation.LandscapeLeft:
                    if (this.phoneLandscape == null)
                    {
                        this.phoneLandscape = new UIRectPositionData();
                    }
                    this.phoneLandscape = UIRectPositionData.FromTransform(base.transform);
                    break;
                }
            }
        }
Esempio n. 2
0
        private void ApplyRect(UIRectPositionData rectPosition)
        {
            if (rectPosition == null || !rectPosition.hasData)
            {
                return;
            }
            RectTransform rectTransform = (RectTransform)base.transform;

            rectTransform.anchoredPosition = rectPosition.anchoredPosition;
            rectTransform.anchorMin        = rectPosition.anchorMin;
            rectTransform.anchorMax        = rectPosition.anchorMax;
            rectTransform.offsetMin        = rectPosition.offsetMin;
            rectTransform.offsetMax        = rectPosition.offsetMax;
        }