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


C# Rect.WithSize方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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


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