예제 #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 UIFontData();
                        }
                        this.tabletPortrait = UIFontData.FromTransform(base.transform);
                        break;

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

                case UIDeviceOrientation.LandscapeRight:
                case UIDeviceOrientation.LandscapeLeft:
                    if (this.phoneLandscape == null)
                    {
                        this.phoneLandscape = new UIFontData();
                    }
                    this.phoneLandscape = UIFontData.FromTransform(base.transform);
                    break;
                }
            }
        }
예제 #2
0
        private void ApplyFont(UIFontData fontData)
        {
            if (fontData == null || !fontData.hasData)
            {
                return;
            }
            Text component = base.GetComponent <Text>();

            if (fontData.bestFit)
            {
                component.resizeTextForBestFit = true;
                component.resizeTextMinSize    = fontData.bestFitMinSize;
                component.resizeTextMaxSize    = fontData.bestFitMaxSize;
            }
            else
            {
                component.fontSize = fontData.fontSize;
            }
        }