示例#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 UINavBarButtonData();
                    }
                    this.tabletPortrait = UINavBarButtonData.FromUIElement(this);
                    break;

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

            case UIDeviceOrientation.LandscapeRight:
            case UIDeviceOrientation.LandscapeLeft:
                if (this.phoneLandscape == null)
                {
                    this.phoneLandscape = new UINavBarButtonData();
                }
                this.phoneLandscape = UINavBarButtonData.FromUIElement(this);
                break;
            }
        }
    }
示例#2
0
 private void ApplyRect(UINavBarButtonData data)
 {
     if (data == null || !data.hasData)
     {
         return;
     }
     this.bg.anchoredPosition = data.bgPos;
     this.bg.sizeDelta        = data.bgSize;
     this.label.fontSize      = data.textFontSize;
     ((RectTransform)this.label.transform).anchoredPosition = data.textPos;
     ((RectTransform)this.label.transform).sizeDelta        = data.textSize;
     this.icon.anchoredPosition = data.iconPos;
     this.icon.sizeDelta        = data.iconSize;
     if (this.bgSelected != null)
     {
         this.bgSelected.gameObject.SetActive(data.selectBgEnabled);
     }
 }