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


C# Vector2.Snap方法代码示例

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


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

示例1: OnGUI


//.........这里部分代码省略.........
                GUI.Label(new Rect(10,5,200,20),"<i><b>General</b></i>", DTStyles.HtmlLabel);
                GUI.Label(new Rect(20,25,50,20),"<b>RMB</b>", DTStyles.HtmlLabel);
                GUI.Label(new Rect(70,25,150,20),"Context Menu", DTStyles.HtmlLabel);
                GUI.Label(new Rect(20, 40, 150, 40), "<b>MMB/\nSpace</b>", DTStyles.HtmlLabel);
                GUI.Label(new Rect(70, 40, 150, 20), "Drag Canvas", DTStyles.HtmlLabel);
                GUI.Label(new Rect(20, 70, 150, 20), "<b>Alt</b>", DTStyles.HtmlLabel);
                GUI.Label(new Rect(70, 70, 150, 20), "Hold to snap to grid", DTStyles.HtmlLabel);
                GUI.Label(new Rect(20, 85, 150, 20), "<b>Del</b>", DTStyles.HtmlLabel);
                GUI.Label(new Rect(70, 85, 150, 20), "Delete selection", DTStyles.HtmlLabel);
                

                GUI.Label(new Rect(10,110,200,20),"<i><b>Add Modules</b></i>", DTStyles.HtmlLabel);
                GUI.Label(new Rect(20,130,180,40),"Hold <b>Ctrl</b> while releasing a\nlink to create & connect", DTStyles.HtmlLabel);
                GUI.Label(new Rect(20, 160, 180, 40), "Drag & Drop splines to create\nPath module", DTStyles.HtmlLabel);
                
                
                 
                GUILayout.EndArea();
            }

            DrawLinks();

            // Init and early catch some events
            Canvas.BeginGUI();

            DrawModules();
            
            Canvas.EndGUI();

            // Draw Selection
            
            DTGUI.PushBackgroundColor(Color.white);//.SkinAwareColor());
            foreach (var mod in Sel.SelectedModules)
                GUI.Box(mod.Properties.Dimensions.ScaleBy(2), "", CurvyStyles.RoundRectangle);
            DTGUI.PopBackgroundColor();

            // Keep dragged Module in view and handle multiselection move
            if (Canvas.IsModuleDrag && !DTGUI.IsLayout)
            {
                Vector2 delta=EV.delta;
                deltaAccu += EV.delta;
                if (EV.alt)
                {
                    delta = deltaAccu.Snap(CurvyProject.Instance.CGGraphSnapping);
                    if (delta == deltaAccu)
                        delta = Vector2.zero;
                }
                if (Sel.SelectedModules.Count > 1)
                {
                    foreach (CGModule mod in Sel.SelectedModules)
                    {
                        mod.Properties.Dimensions.position += delta;
                    }
                    if (!EV.alt || delta!=Vector2.zero)
                        deltaAccu = Vector2.zero;
                }
                var m = (Canvas.MouseOverModule) ? Canvas.MouseOverModule : Sel.SelectedModule;
                if (m)
                GUI.ScrollTowards(m.Properties.Dimensions, 0.8f);
            }

            // Linking in progress?
            if (Canvas.IsLinkDrag)
            {
                var linkstyle = (Canvas.LinkDragFrom.OnRequestModule != null) ? CurvyStyles.RequestLineTexture : CurvyStyles.LineTexture;
                Handles.DrawBezier(Canvas.LinkDragFrom.Origin, EV.mousePosition, Canvas.LinkDragFrom.Origin + new Vector2(40, 0), EV.mousePosition + new Vector2(-40, 0), Color.white, linkstyle, 2);
            }

            GUI.EndScrollView(true);
            
            // Selection
            if (Canvas.IsSelectionRectDrag)
                DrawSelectionRect();

            // Statusbar
            DrawStatusbar();

            // IPE
            SyncIPE();
            
            mDoRepaint=mDoRepaint || Canvas.IsCanvasDrag || Canvas.IsLinkDrag || Canvas.IsSelectionRectDrag || EV.type==EventType.MouseMove || mShowDebug.isAnimating || Canvas.Scroll.isAnimating;


            // Disable Title edit mode?
            if (editTitleModule != null)
            {
                if ((EV.isKey && (EV.keyCode == KeyCode.Escape || EV.keyCode == KeyCode.Return)) ||
                    Sel.SelectedModule != editTitleModule
                    )
                {
                    editTitleModule = null;
                    //GUI.FocusControl("");
                    mDoRepaint = true;
                }
            }


            if (mDoRepaint)
                Repaint();
        }
开发者ID:scumbly,项目名称:Organ-Grinder,代码行数:101,代码来源:CGGraph.cs


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