当前位置: 首页>>代码示例>>C#>>正文


C# Rect.PadSides方法代码示例

本文整理汇总了C#中UnityEngine.Rect.PadSides方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.PadSides方法的具体用法?C# Rect.PadSides怎么用?C# Rect.PadSides使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Rect的用法示例。


在下文中一共展示了Rect.PadSides方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawWorkspacesList

        public void DrawWorkspacesList(IPlatformDrawer platform, Rect bounds, List<WorkspacesListItem> items)
        {
            platform.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13);

            var scrollBounds = bounds.Translate(15, 0).Pad(0, 0, 15, 0);
            bounds = bounds.PadSides(15);


            var headerRect = bounds.WithHeight(40);

            platform.DrawLabel(headerRect, "Workspaces", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter);

            var unpaddedItemRect = bounds.Below(headerRect).WithHeight(100);

            var workspaces = items.ToArray();
         
            var position = scrollBounds.Below(headerRect).Clip(scrollBounds).Pad(0, 0, 0, 55);
            var usedRect = position.Pad(0, 0, 15, 0).WithHeight((unpaddedItemRect.height + 1) * workspaces.Length);
            _scrollPos = GUI.BeginScrollView(position, _scrollPos, usedRect);
            foreach (var db in workspaces)
            {
                var workspace = db;
                platform.DrawStretchBox(unpaddedItemRect, CachedStyles.WizardListItemBoxStyle, 2);
                var itemRect = unpaddedItemRect.PadSides(15);
                var titleRect = itemRect.WithHeight(40);

                platform.DrawLabel(titleRect, db.Workspace.Title, CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopLeft);

                var infoRect = itemRect.Below(titleRect).WithHeight(30);
                //(platform as UnityDrawer).DrawInfo(infoRect, string.Format("Namespace: {0}\nPath: {1}", db.GraphConfiguration.Namespace ?? "-", db.GraphConfiguration.FullPath));


                var openButton = new Rect().WithSize(80, 25).InnerAlignWithBottomRight(itemRect);
                var configButton = openButton.LeftOf(openButton).Translate(-2, 0);
                var deleteButton = configButton.LeftOf(configButton).Translate(-2, 0);

                platform.DoButton(openButton, "Open", ElementDesignerStyles.DarkButtonStyle, () =>
                {
                    Execute(new OpenWorkspaceCommand() { Workspace = workspace.Workspace });
                    EnableWizard = false;
                });
                var db1 = db;
                platform.DoButton(configButton, "Config", ElementDesignerStyles.DarkButtonStyle, () => InvokeConfigFor(db1));
                platform.DoButton(deleteButton, "Remove", ElementDesignerStyles.DarkButtonStyle, () => { Execute(new RemoveWorkspaceCommand() { Workspace = workspace.Workspace }); });
                //platform.DoButton(showButton, "Show In Explorer", ElementDesignerStyles.ButtonStyle, () => { });


                unpaddedItemRect = unpaddedItemRect.Below(unpaddedItemRect).Translate(0, 1);

            }

            GUI.EndScrollView(true);

        }
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:54,代码来源:WorkspacesUISystem.cs

示例2: OnGUI

        void OnGUI()
        {
            var bounds = new Rect(0, 0, this.position.width, this.position.height);
            var platform = InvertGraphEditor.PlatformDrawer;

            InvertApplication.SignalEvent<IDrawDatabasesList>(_=>
            {
                _.DrawDatabasesList(platform,bounds,Items);
            });

            platform.DoButton(new Rect().WithSize(80,30).InnerAlignWithBottomLeft(bounds.PadSides(15)),"Close",ElementDesignerStyles.ButtonStyle,Close);

        }
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:13,代码来源:DatabaseListWindow.cs

示例3: DrawActionDialog

        public void DrawActionDialog(IPlatformDrawer platform, Rect bounds, ActionItem item, Action cancel = null)
        {
            if (item == null) return;

            platform.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13);

            bounds = bounds.PadSides(15);

            var descriptionHeight = string.IsNullOrEmpty(item.Description) ? 50 : platform.CalculateTextHeight(item.Description, CachedStyles.BreadcrumbTitleStyle, bounds.width) + 60;

            var headerRect = bounds.WithHeight(40);
            var iconRect = bounds.WithSize(41, 41);
            
            var descriptionRect = headerRect.Below(headerRect).Translate(0,-22).WithHeight(descriptionHeight);
            var inspectorRect = bounds.Below(descriptionRect).Clip(bounds);
            var executeButtonRect = new Rect()
                .WithSize(100, 30)
                .InnerAlignWithBottomRight(bounds);

            if (!_inspectors.ContainsKey(item))
            {
                var uFrameMiniInspector = new uFrameMiniInspector(item.Command);
                _inspectors.Add(item, uFrameMiniInspector);
            }
            var inspector = _inspectors[item];
            var inspectorHeight = inspector.Height;


            _scrollPosition = GUI.BeginScrollView(bounds.AddHeight(-30).AddWidth(15), _scrollPosition,
                bounds.WithHeight(headerRect.height + iconRect.height + descriptionRect.height + inspectorHeight));

            platform.DrawLabel(headerRect, item.Title, CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.MiddleCenter);
            platform.DrawImage(iconRect, string.IsNullOrEmpty(item.Icon) ? "CreateEmptyDatabaseIcon" : item.Icon, true);
            platform.DrawLabel(descriptionRect, item.Description, CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.MiddleLeft);

            inspector.Draw(descriptionRect.WithHeight(inspectorHeight).Pad(0,0,10,0).Below(descriptionRect));

            //Draw generic inspector


                GUI.EndScrollView();
            if ( cancel != null)
            {
                platform.DoButton(executeButtonRect.InnerAlignWithBottomLeft(bounds), "Cancel", ElementDesignerStyles.DarkButtonStyle, cancel);
            }

            platform.DoButton(executeButtonRect, string.IsNullOrEmpty(item.Verb) ? "Create" : item.Verb, ElementDesignerStyles.DarkButtonStyle, () =>
            {
                InvertApplication.Execute(item.Command);
            });
        }
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:51,代码来源:ActionsUISystem.cs

示例4: DrawGraphsList

        public void DrawGraphsList(Rect bounds, List<IGraphData> items)
        {

            PlatformDrawer.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13);
            
            var scrollBounds = bounds.Translate(15,0).Pad(0,0,15,0);
            
            bounds = bounds.PadSides(15);


            var headerRect = bounds.WithHeight(40);
             
            PlatformDrawer.DrawLabel(headerRect, string.Format("{0} Graphs", WorkspaceService.CurrentWorkspace.Title), CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter);

            var unpaddedItemRect = bounds.Below(headerRect).WithHeight(50);

            var databasesListItems = items.ToArray();
         
            var position = scrollBounds.Below(headerRect).Clip(scrollBounds).Pad(0, 0, 0, 55);
            var usedRect = position.Pad(0, 0, 15, 0).WithHeight((unpaddedItemRect.height + 1)*databasesListItems.Length);
            
            _scrollPos = GUI.BeginScrollView(position, _scrollPos, usedRect);

            foreach (var db in databasesListItems)
            {

                var db1 = db;
                var isGraphInWorkspace = WorkspaceService.CurrentWorkspace != null && WorkspaceService.CurrentWorkspace.Graphs.Contains(db1);
                var cColor = GUI.color;
                var mColor = new Color(cColor.r, cColor.g, cColor.b, 0.3f);
                if (!isGraphInWorkspace) GUI.color = mColor;

                PlatformDrawer.DrawStretchBox(unpaddedItemRect,CachedStyles.WizardListItemBoxStyle,2);
               
                if(isGraphInWorkspace)
                PlatformDrawer.DoButton(unpaddedItemRect.TopHalf(),"",CachedStyles.ClearItemStyle, () =>
                {
                    Execute(new LambdaCommand("Open Graph", () =>
                    {
                        WorkspaceService.CurrentWorkspace.AddGraph(db1);
                        WorkspaceService.CurrentWorkspace.CurrentGraphId = db1.Identifier;
                        EnableGraphManagementhWizard = false;
                    }));
                });
                
                var itemRect = unpaddedItemRect.PadSides(15);
                var titleRect = itemRect.WithHeight(40);

                PlatformDrawer.DrawLabel(titleRect,db.Title,CachedStyles.WizardSubBoxTitleStyle,DrawingAlignment.TopLeft);

                var infoRect = itemRect.Below(titleRect).WithHeight(38);
                //(PlatformDrawer as UnityDrawer).DrawInfo(infoRect, string.Format("Namespace: {0}\nPath: {1}", db.GraphConfiguration.Namespace ?? "-", db.GraphConfiguration.FullPath));


                var openButton = new Rect().WithSize(80,25).InnerAlignWithBottomRight(itemRect).AlignHorisonallyByCenter(itemRect);
                var configButton = openButton.LeftOf(openButton).Translate(-2,0);
                var exportButton = openButton.LeftOf(configButton).Translate(-2, 0);
                var deleteButton = openButton.LeftOf(exportButton).Translate(-2, 0);


                GUI.color = cColor;
                PlatformDrawer.DoButton(openButton, isGraphInWorkspace ? "Open" : "Import", ElementDesignerStyles.DarkButtonStyle, () =>
                {
                    
                    /* OPEN DATABASE */
                    Execute(new LambdaCommand("Open Graph", () =>
                    {
                        WorkspaceService.CurrentWorkspace.AddGraph(db1);
                        WorkspaceService.CurrentWorkspace.CurrentGraphId = db1.Identifier;
                        EnableGraphManagementhWizard = false;
                    }));
                    //DatabaseListWindow.Init(new Vector2(Screen.currentResolution.width / 2 - 200, Screen.currentResolution.height/2- 300));

                });
                //PlatformDrawer.DoButton(configButton, "Config", ElementDesignerStyles.ButtonStyle, () => { /* CONFIG DATABASE */ });
                //PlatformDrawer.DoButton(deleteButton, "Delete", ElementDesignerStyles.ButtonStyle, () => { /* SHOW DATABASE IN EXPLORER */ });
                //PlatformDrawer.DoButton(exportButton, "Export", ElementDesignerStyles.ButtonStyle, () => { /* SHOW DATABASE IN EXPLORER */ });
               
                unpaddedItemRect = unpaddedItemRect.Below(unpaddedItemRect).Translate(0,1);

            }
            GUI.EndScrollView(true);
        }
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:83,代码来源:GraphManagementUISystem.cs

示例5: AfterDrawDesignerWindow

        public void AfterDrawDesignerWindow(Rect windowRect)
        {
            _deltaTime = (float)(DateTime.Now - _lastUpdate).TotalMilliseconds;

            var firstUnpaddedItemRect = windowRect.WithSize(300, 150).InnerAlignWithBottomRight(windowRect).Translate(-15,-70);
            
            foreach (var item in Items.ToArray())
            {

                var unpaddedItemRect = firstUnpaddedItemRect.AboveAll(firstUnpaddedItemRect, item.Index);

                if (item.TimeLeft > item.Time - 400)
                {
                    item.TimeLeft -= _deltaTime;
                    item.AnimatedX = Mathf.Lerp(400, 0, (item.Time - item.TimeLeft) / 400);
                }
                else if (!item.RequireClose && item.TimeLeft <= 400)
                {
                    item.TimeLeft -= _deltaTime;
                    if (item.TimeLeft < 0)
                    {
                        Items.Remove(item);
                        continue;
                    }
                    item.AnimatedX = Mathf.Lerp(400, 0, item.TimeLeft/400);
                }


                if (!item.RequireClose)
                {
                    item.TimeLeft -= _deltaTime;
                }
                //else item.AnimatedX = 0;
                
                var paddedItemRect = unpaddedItemRect.WithOrigin(unpaddedItemRect.x+item.AnimatedX, unpaddedItemRect.y).PadSides(15);

                PlatformDrawer.DrawStretchBox(paddedItemRect,CachedStyles.TooltipBoxStyle,14);
                if (item.RequireClose){
                    var closeButtonRect = new Rect().WithSize(16, 16).InnerAlignWithUpperRight(paddedItemRect).Translate(-12,12);
                        PlatformDrawer.DrawImage(closeButtonRect, "CloseIcon", true);
                    var item1 = item;
                    PlatformDrawer.DoButton(closeButtonRect.PadSides(-3),"",CachedStyles.ClearItemStyle,m=>
                    {
                        item1.RequireClose = false;
                    });
                }
                
                paddedItemRect = paddedItemRect.PadSides(15);
                PlatformDrawer.DrawLabel(paddedItemRect.Pad(0,0,40,0),item.Message,CachedStyles.BreadcrumbTitleStyle,item.Actions == null || item.Actions.Length == 0 ? DrawingAlignment.MiddleLeft : DrawingAlignment.TopLeft);
                PlatformDrawer.DrawImage(paddedItemRect.WithSize(33,33).InnerAlignWithBottomRight(paddedItemRect).AlignHorisonallyByCenter(paddedItemRect),item.Icon,true);

                if (item.Actions != null && item.Actions.Length > 0)
                {
                    Rect lastItemRect = new Rect().WithSize(0, 27).InnerAlignWithBottomLeft(paddedItemRect).Translate(0, 10);
                    foreach (var actionItem in item.Actions)
                    {
                        var itemRect =
                            lastItemRect.WithSize(
                                PlatformDrawer.CalculateTextSize(actionItem.Title, ElementDesignerStyles.ButtonStyle)
                                    .x+15, 27).RightOf(lastItemRect);

                       PlatformDrawer.DoButton(itemRect,actionItem.Title,ElementDesignerStyles.ButtonStyle,actionItem.Action);
                        lastItemRect = itemRect;
                    }
                }

           


            }

            _lastUpdate = DateTime.Now;
        }
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:73,代码来源:DesignerNotificationSystem.cs

示例6: DrawActionsPanel

        //TODO WIZARDS: Add scrolling (drawer needs to be extended to support scrolling / or use native unity stuff)
        public void DrawActionsPanel(IPlatformDrawer platform, Rect bounds, List<ActionItem> actions, Action<ActionItem,Vector2> primaryAction,
            Action<ActionItem,Vector2> secondaryAction = null)
        {
            platform.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13);

            bounds = bounds.PadSides(15);
            var headerRect = new Rect(bounds.WithHeight(40));

            platform.DrawLabel(headerRect, "Actions", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter);

            bounds = bounds.Below(headerRect).Clip(bounds);

            var buttonSize = 100;
            var buttonsPerRow = (int)bounds.width / (int)buttonSize;
            var buttonIndex = 0;
            var padding = (bounds.width % buttonSize) / (buttonsPerRow - 1);
            var itemRect = new Rect().Align(bounds).WithSize(buttonSize, buttonSize);

            foreach (var action in actions)
            {

                platform.DrawStretchBox(itemRect, CachedStyles.WizardActionButtonStyle, 0);

                var action1 = action;
                platform.DoButton(itemRect,"",CachedStyles.ClearItemStyle, m =>
                {
                    primaryAction(action1, m);
                }, m =>
                {
                    if (secondaryAction != null)
                    {
                        secondaryAction(action1, m);
                    }
                });

                var imageRect = itemRect
                    .WithSize(41, 41)
                    .CenterInsideOf(itemRect)
                    .AlignHorisontally(itemRect)
                    .Translate(0, 10);

                var titleRect = itemRect
                    .Below(imageRect)
                    .Clip(itemRect)
                    .Pad(5, 0, 10, 0)
                    .Translate(0, -2);

                platform.DrawImage(imageRect, string.IsNullOrEmpty(action.Icon) ? "CreateEmptyDatabaseIcon" : action.Icon, true);
                platform.DrawLabel(titleRect, action.Title, CachedStyles.ListItemTitleStyle, DrawingAlignment.MiddleCenter);

                buttonIndex++;

                if (buttonIndex % buttonsPerRow == 0)
                {
                    itemRect = itemRect.Below(itemRect).AlignVertically(bounds).Translate(0, 10);
                }
                else
                {
                    itemRect = itemRect.RightOf(itemRect).Translate(padding, 0);
                }

            }
        }
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:64,代码来源:ActionsUISystem.cs

示例7: DrawTabs

        public void DrawTabs(IPlatformDrawer platform, Rect tabsRect)
        {
            var designerWindow = DiagramViewModel.NavigationViewModel.DesignerWindow;
            if (designerWindow != null && designerWindow.Designer != null)
            {
                var x = 1f;
                foreach (var tab in DiagramViewModel.NavigationViewModel.Tabs.ToArray())
                {
                    if (tab == null) continue;
                    if (tab.Title == null)
                        continue;

                    var textSize = platform.CalculateTextSize(tab.Title, CachedStyles.TabTitleStyle);
                    
                    var buttonRect=  new Rect()
                        .AlignAndScale(tabsRect)
                        .WithWidth(Math.Max(textSize.x + 21 + 16,60))
                        .Translate(x,0);

                    var buttonBoxRect = new Rect().AlignAndScale(buttonRect)
                        .WithWidth(textSize.x + 10);
                    
                    var textRect = new Rect()
                        .AlignAndScale(buttonRect)
                        .Pad(7, 0, 7, 0);

                    var closeButton = new Rect()
                        .WithSize(16, 16)
                        .AlignTopRight(buttonRect)
                        .AlignHorisonallyByCenter(buttonRect)
                        .Translate(-7,1);
                    

                    platform.DrawStretchBox(buttonRect,tab.State == NavigationItemState.Current ? CachedStyles.TabBoxActiveStyle : CachedStyles.TabBoxStyle,10);

                    platform.DrawLabel(textRect,tab.Title,CachedStyles.TabTitleStyle);

                    var tab1 = tab;
                    platform.DoButton(buttonBoxRect,"",CachedStyles.ClearItemStyle, m =>
                    {
                        if (tab1.NavigationAction != null) tab1.NavigationAction(m);
                    }, m =>
                    {
                        if (tab1.NavigationActionSecondary != null) tab1.NavigationActionSecondary(m);
                    });

                    platform.DoButton(closeButton,"",CachedStyles.TabCloseButton, m =>
                    {
                        if (tab1.CloseAction != null) tab1.CloseAction(m);
                    });

//                    if (GUILayout.Button(tab.Name,
//                        isCurrent
//                            ? ElementDesignerStyles.TabBoxStyle
//                            : ElementDesignerStyles.TabBoxActiveStyle,GUILayout.MinWidth(150)))
//                    {
//                        var projectService = InvertGraphEditor.Container.Resolve<WorkspaceService>();
//                   
//                        if (Event.current.button == 1)
//                        {
//                         
//                           var isLastGraph = projectService.CurrentWorkspace.Graphs.Count() <= 1;
//
//                           if (!isLastGraph)
//                            {
//                                var tab1 = tab;
//                                projectService.Repository.RemoveAll<WorkspaceGraph>(p=>p.WorkspaceId == projectService.CurrentWorkspace.Identifier && p.GraphId == tab1.Identifier);
//                                var lastGraph = projectService.CurrentWorkspace.Graphs.LastOrDefault();
//                                if (isCurrent && lastGraph != null)
//                                {
//                                    designerWindow.SwitchDiagram(lastGraph);
//                                }
//                            
//                            }
//                        }
//                        else
//                        {
//                            designerWindow.SwitchDiagram(projectService.CurrentWorkspace.Graphs.FirstOrDefault(p => p.Identifier == tab.Identifier));    
//                        }
//                        
//                    }
//
//                    var butRect = GUILayoutUtility.GetLastRect();
                    x += buttonRect.width+2;
                }

                var newTabButtonRect =
                    new Rect().WithSize(27, 27).Align(tabsRect).AlignHorisonallyByCenter(tabsRect).Translate(x+2, 0);

                platform.SetTooltipForRect(newTabButtonRect,"Create or import new graphs");

                platform.DoButton(newTabButtonRect,"",ElementDesignerStyles.WizardActionButtonStyleSmall,()=>{ InvertApplication.SignalEvent<INewTabRequested>(_=>_.NewTabRequested());});
                //platform.DrawImage(newTabButtonRect,"",true);
                platform.DrawImage(newTabButtonRect.PadSides(6),"PlusIcon_Micro",true);


                //   GUILayout.FlexibleSpace();
                //   GUILayout.EndHorizontal();
                //   GUILayout.EndArea();
            }
//.........这里部分代码省略.........
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:101,代码来源:DiagramDrawer.cs

示例8: DrawBreadcrumbs

        public void DrawBreadcrumbs(IPlatformDrawer platform,  float y)
        {

            var navPanelRect = new Rect(4, y, 60, 30f);
            var breadcrumbsRect = new Rect(64, y, Bounds.width-44, 30f);
            platform.DrawRect(Bounds.WithOrigin(0,y).WithHeight(30), InvertGraphEditor.Settings.BackgroundColor);

            var back = new Rect().WithSize(30, 30).PadSides(2).CenterInsideOf(navPanelRect.LeftHalf());
            platform.DoButton(back, "", ElementDesignerStyles.WizardActionButtonStyleSmall,
                () =>
                {
                    InvertApplication.Execute(new NavigateBackCommand());
                });
            platform.DrawImage(back.PadSides(4), "BackIcon", true);

            var forward = new Rect().WithSize(30, 30).PadSides(2).CenterInsideOf(navPanelRect.RightHalf());
            platform.DoButton(forward, "", ElementDesignerStyles.WizardActionButtonStyleSmall,
                () =>
                {
                    InvertApplication.Execute(new NavigateForwardCommand());
                });
            platform.DrawImage(forward.PadSides(4),"ForwardIcon",true);

            //var color = new Color(InvertGraphEditor.Settings.BackgroundColor.r * 0.8f, InvertGraphEditor.Settings.BackgroundColor.g * 0.8f, InvertGraphEditor.Settings.BackgroundColor.b * 0.8f, 1f);
            //platform.DrawRect(rect, color);
            
//            var lineRect = new Rect(rect);
//            lineRect.height = 2;
//            lineRect.y = y + 38f;
//            platform.DrawRect(lineRect, new Color(InvertGraphEditor.Settings.BackgroundColor.r * 0.6f, InvertGraphEditor.Settings.BackgroundColor.g * 0.6f, InvertGraphEditor.Settings.BackgroundColor.b * 0.6f, 1f));
//            
//            
//            var first = true;
//            if (_cachedPaths != null)
//            foreach (var item in _cachedPaths)
//            {
//                var item1 = item;
//                platform.DoButton(new Rect(x, rect.y + 20 - (item.Value.y / 2), item.Value.x, item.Value.y), first ? item.Key.Name : "< " + item.Key.Name, first ? CachedStyles.GraphTitleLabel : CachedStyles.ItemTextEditingStyle,
//                    () =>
//                    {
//                        InvertApplication.Execute(new LambdaCommand(() =>
//                        {
//                            DiagramViewModel.GraphData.PopToFilter(item1.Key);
//                        }));
//                    });
//                x += item.Value.x + 15;
//                first = false;
//            }


            var x = 1f;

            var styles = DiagramViewModel.NavigationViewModel.BreadcrumbsStyle;
            var iconsTine = new Color(1, 1, 1, 0.5f);

            foreach (var usitem in DiagramViewModel.NavigationViewModel.Breadcrubs.ToArray())
            {
                var item = usitem;
                var textSize = platform.CalculateTextSize(usitem.Title, CachedStyles.BreadcrumbTitleStyle);
                float buttonContentPadding = 5;
                float buttonIconsPadding= 5;
                bool useSpecIcon = !string.IsNullOrEmpty(item.SpecializedIcon);
                var buttonWidth = textSize.x + buttonContentPadding*2 + 8;
                if (!string.IsNullOrEmpty(item.Icon)) buttonWidth += buttonIconsPadding + 16;
                if (useSpecIcon) buttonWidth += buttonIconsPadding + 16;
               
                var buttonRect = new Rect()
                    .AlignAndScale(breadcrumbsRect)
                    .WithWidth(buttonWidth)
                    .PadSides(3)
                    .Translate(x, 0);

                var icon1Rect = new Rect()
                    .WithSize(16, 16)
                    .AlignTopRight(buttonRect)
                    .AlignHorisonallyByCenter(buttonRect)
                    .Translate(-buttonContentPadding, 0);

                var icon2Rect = new Rect()
                    .WithSize(16, 16)
                    .Align(buttonRect)
                    .AlignHorisonallyByCenter(buttonRect)
                    .Translate(buttonContentPadding, 0);

                var textRect = new Rect()
                    .WithSize(textSize.x, textSize.y)
                    .Align(useSpecIcon ? icon2Rect : buttonRect)
                    .AlignHorisonallyByCenter(buttonRect)
                    .Translate(useSpecIcon ? buttonIconsPadding + 16 : buttonContentPadding, -1);

                var dotRect = new Rect()
                    .WithSize(16, 16)
                    .RightOf(buttonRect)
                    .AlignHorisonallyByCenter(buttonRect)
                    .Translate(-3,0);

                platform.DoButton(buttonRect, "", item.State == NavigationItemState.Current ? CachedStyles.BreadcrumbBoxActiveStyle : CachedStyles.BreadcrumbBoxStyle, item.NavigationAction);
                platform.DrawLabel(textRect, item.Title, CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.MiddleCenter);
                platform.DrawImage(icon1Rect, styles.GetIcon(item.Icon,iconsTine), true);

//.........这里部分代码省略.........
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:101,代码来源:DiagramDrawer.cs

示例9: DrawDatabasesList

        public void DrawDatabasesList(IPlatformDrawer Drawer, Rect bounds, List<DatabasesListItem> items)
        {

            Drawer.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13);
            
            var scrollBounds = bounds.Translate(15,0).Pad(0,0,15,0);
            
            bounds = bounds.PadSides(15);


            var headerRect = bounds.WithHeight(40);
             
            Drawer.DrawLabel(headerRect, "Databases", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter);

            var unpaddedItemRect = bounds.Below(headerRect).WithHeight(150);

            var databasesListItems = items.ToArray();
         
            var position = scrollBounds.Below(headerRect).Clip(scrollBounds).Pad(0, 0, 0, 55);
            var usedRect = position.Pad(0, 0, 15, 0).WithHeight((unpaddedItemRect.height + 1)*databasesListItems.Length);
            
            _scrollPos = GUI.BeginScrollView(position, _scrollPos, usedRect);

            foreach (var db in databasesListItems)
            {

                Drawer.DrawStretchBox(unpaddedItemRect,CachedStyles.WizardListItemBoxStyle,2);
                var itemRect = unpaddedItemRect.PadSides(15);
                var titleRect = itemRect.WithHeight(40);

                Drawer.DrawLabel(titleRect,db.GraphConfiguration.Title,CachedStyles.WizardSubBoxTitleStyle,DrawingAlignment.TopLeft);

                var infoRect = itemRect.Below(titleRect).WithHeight(50);
                (Drawer as UnityDrawer).DrawInfo(infoRect,string.Format("Namespace: {0}\nPath: {1}",db.GraphConfiguration.Namespace ?? "-",db.GraphConfiguration.FullPath));


                var openButton = new Rect().WithSize(80,25).InnerAlignWithBottomRight(itemRect);
                var configButton = openButton.LeftOf(openButton).Translate(-2,0);
                var showButton = configButton.WithWidth(120).InnerAlignWithBottomLeft(itemRect);

                Drawer.DoButton(openButton, "Open", ElementDesignerStyles.DarkButtonStyle, () =>
                {
                    Signal<IChangeDatabase>(_=>_.ChangeDatabase(db.GraphConfiguration));
                });

                Drawer.SetTooltipForRect(openButton,"Open this database.");

                var db1 = db;
                Drawer.DoButton(configButton, "Config", ElementDesignerStyles.DarkButtonStyle, () =>
                {
                    SelectedItem = new ActionItem()
                    {
                        Command = new EditDatabaseCommand()
                        {
                            Namespace = db1.GraphConfiguration.Namespace,
                            CodePath = db1.GraphConfiguration.CodeOutputPath,
                            Configuration = db1.GraphConfiguration as uFrameDatabaseConfig
                        },

                        Description = "Configuration",
                        Title = string.Format("Configure {0}", db1.GraphConfiguration.Title),
                        Verb = "Apply"
                    };
                });
                Drawer.DoButton(showButton, "Show In Explorer", ElementDesignerStyles.DarkButtonStyle, () =>
                {
                    EditorUtility.RevealInFinder(db1.GraphConfiguration.FullPath);
                });

                unpaddedItemRect = unpaddedItemRect.Below(unpaddedItemRect).Translate(0,1);

            }
            GUI.EndScrollView(true);
        }
开发者ID:InvertGames,项目名称:uFrame.Editor,代码行数:74,代码来源:DatabasesUISystem.cs


注:本文中的UnityEngine.Rect.PadSides方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。