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


C# Rect.Translate方法代码示例

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


在下文中一共展示了Rect.Translate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Window

        /// <summary>
        ///     Draws the OnGUI window.
        /// </summary>
        private void Window(int windowId)
        {
            try
            {
                compactModeRect = new Rect(position.width - 70.0f * GuiDisplaySize.Offset, 5.0f, 65.0f * GuiDisplaySize.Offset, 20.0f);

                // Draw the compact mode toggle.
                if (GUI.Toggle(compactModeRect, compactMode, "COMPACT", buttonStyle) != compactMode)
                {
                    hasChanged = true;
                    compactCheck = 2;
                    compactRight = position.xMax;
                    compactMode = !compactMode;
                }

                // When not in compact mode draw the 'All Stages' and 'Atmospheric' toggles.
                if (!compactMode)
                {
                    if (GUI.Toggle(new Rect(position.width - 143.0f * GuiDisplaySize.Offset, 5.0f, 70.0f * GuiDisplaySize.Offset, 20.0f), showSettings, "SETTINGS", buttonStyle) != showSettings)
                    {
                        hasChanged = true;
                        showSettings = !showSettings;
                    }

                    if (GUI.Toggle(new Rect(position.width - 226.0f * GuiDisplaySize.Offset, 5.0f, 80.0f * GuiDisplaySize.Offset, 20.0f), showAllStages, "ALL STAGES", buttonStyle) != showAllStages)
                    {
                        hasChanged = true;
                        showAllStages = !showAllStages;
                    }

                    if (GUI.Toggle(new Rect(position.width - 324.0f * GuiDisplaySize.Offset, 5.0f, 95.0f * GuiDisplaySize.Offset, 20.0f), showAtmosphericDetails, "ATMOSPHERIC", buttonStyle) != showAtmosphericDetails)
                    {
                        hasChanged = true;
                        showAtmosphericDetails = !showAtmosphericDetails;
                    }

                    bodiesListPosition = new Rect(position.width - 452.0f * GuiDisplaySize.Offset, 5.0f, 125.0f * GuiDisplaySize.Offset, 20.0f);
                    bodiesList.enabled = GUI.Toggle(bodiesListPosition, bodiesList.enabled, "BODY: " + CelestialBodies.SelectedBody.Name.ToUpper(), buttonStyle);
                    bodiesList.SetPosition(bodiesListPosition.Translate(position));
                }
                else
                {
                    if (GUI.Toggle(new Rect(position.width - 133.0f * GuiDisplaySize.Offset, 5.0f, 60.0f * GuiDisplaySize.Offset, 20.0f), showAtmosphericDetails, "ATMO", buttonStyle) != showAtmosphericDetails)
                    {
                        hasChanged = true;
                        showAtmosphericDetails = !showAtmosphericDetails;
                    }
                }

                // Draw the main informational display box.
                if (!compactMode)
                {
                    GUILayout.BeginHorizontal(areaStyle);
                    DrawStageNumbers();
                    DrawPartCount();
                    DrawCost();
                    DrawMass();
                    DrawIsp();
                    DrawThrust();
                    DrawTorque();
                    DrawTwr();
                    DrawDeltaV();
                    DrawBurnTime();
                    GUILayout.EndHorizontal();

                    if (showAtmosphericDetails && !compactMode)
                    {
                        GUILayout.BeginVertical(areaSettingStyle);
                        DrawAtmosphericDetails();
                        GUILayout.EndVertical();
                    }

                    if (showSettings)
                    {
                        GUILayout.BeginVertical(areaSettingStyle);
                        DrawSettings();
                        GUILayout.EndVertical();
                    }
                }
                else // Draw only a few details when in compact mode.
                {
                    GUILayout.BeginHorizontal(areaStyle);
                    DrawStageNumbers();
                    DrawTwr();
                    DrawDeltaV();
                    GUILayout.EndHorizontal();
                }

                GUI.DragWindow();
            }
            catch (Exception ex)
            {
                Logger.Exception(ex, "BuildAdvanced.Window()");
            }
        }
开发者ID:d5039m,项目名称:KerbalEngineer,代码行数:98,代码来源:BuildAdvanced.cs

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

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