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


C# Rect类代码示例

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


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

示例1: BeginScrollView

 internal static void BeginScrollView(Rect position, Vector2 scrollPosition, Rect viewRect, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar)
 {
     s_ScrollPos = scrollPosition;
     s_ViewRect = viewRect;
     s_Position = position;
     GUIClip.Push(position, new Vector2(Mathf.Round((-scrollPosition.x - viewRect.x) - ((viewRect.width - position.width) * 0.5f)), Mathf.Round((-scrollPosition.y - viewRect.y) - ((viewRect.height - position.height) * 0.5f))), Vector2.zero, false);
 }
开发者ID:demelev,项目名称:projectHL,代码行数:7,代码来源:PreviewGUI.cs

示例2: ApplySetPieces

        public static void ApplySetPieces(World world)
        {
            var map = world.Map;
            int w = map.Width, h = map.Height;

            Random rand = new Random();
            HashSet<Rect> rects = new HashSet<Rect>();
            foreach (var dat in setPieces)
            {
                int size = dat.Item1.Size;
                int count = rand.Next(dat.Item2, dat.Item3);
                for (int i = 0; i < count; i++)
                {
                    IntPoint pt = new IntPoint();
                    Rect rect;

                    int max = 50;
                    do
                    {
                        pt.X = rand.Next(0, w);
                        pt.Y = rand.Next(0, h);
                        rect = new Rect() { x = pt.X, y = pt.Y, w = size, h = size };
                        max--;
                    } while ((Array.IndexOf(dat.Item4, map[pt.X, pt.Y].Terrain) == -1 ||
                             rects.Any(_ => Rect.Intersects(rect, _))) &&
                             max > 0);
                    if (max <= 0) continue;
                    dat.Item1.RenderSetPiece(world, pt);
                    rects.Add(rect);
                }
            }
        }
开发者ID:BlackRayquaza,项目名称:MMOE,代码行数:32,代码来源:SetPieces.cs

示例3: FromJSON

    public void FromJSON(Ferr_JSONValue aJSON)
    {
        Ferr_JSONValue json = new Ferr_JSONValue();
        applyTo = (Ferr2DT_TerrainDirection)aJSON["applyTo", (int)Ferr2DT_TerrainDirection.Top];
        zOffset   = aJSON["zOffset",0f];
        yOffset   = aJSON["yOffset",0f];
        capOffset = aJSON["capOffset",0f];
        leftCap = new Rect(
            aJSON["leftCap.x",     0f],
            aJSON["leftCap.y",     0f],
            aJSON["leftCap.xMax",  0f],
            aJSON["leftCap.yMax",  0f]);
        rightCap = new Rect(
            aJSON["rightCap.x",    0f],
            aJSON["rightCap.y",    0f],
            aJSON["rightCap.xMax", 0f],
            aJSON["rightCap.yMax", 0f]);

        Ferr_JSONValue bodyArr = json["body"];
        body = new Rect[bodyArr.Length];
        for (int i = 0; i < body.Length; i++) {
            body[i] = new Rect(
                bodyArr[i]["x",    0 ],
                bodyArr[i]["y",    0 ],
                bodyArr[i]["xMax", 50],
                bodyArr[i]["yMax", 50]);
        }
    }
开发者ID:shlyahovchuk,项目名称:Racing,代码行数:28,代码来源:Ferr2DT_TerrainMaterial.cs

示例4: SpawnGibs

    public void SpawnGibs(GibType gType, Rect area, int amount, float force  = 10, float lifeSpan = 5)
    {
        List<Gib> eList;

        if (_gibs.TryGetValue(gType, out eList))
        {
            for (int a = 0; a < amount; a++)
            {
                Gib g = null;

                for (int i = 0; i < eList.Count; i++)
                {
                    if (!eList[i].gameObject.activeInHierarchy)
                    {
                        g = eList[i];
                        break;
                    }
                }

                if (!g)
                {
                    g = NewGib(gType);
                }

                var position = new Vector2(Random.Range(area.xMin, area.xMax), Random.Range(area.yMin, area.yMax));

                g.Spawn(gType, position, force, lifeSpan);
            }
        }
    }
开发者ID:BartMartner,项目名称:SecretGame,代码行数:30,代码来源:GibManager.cs

示例5: OnGUI

	void OnGUI()
	{
		if (game.allowInput)
		{
			winRect = GUILayout.Window(0, winRect, theWindow, "Game GUI");
		}
	}
开发者ID:daren511,项目名称:ThroneWarsServer,代码行数:7,代码来源:SampleGui.cs

示例6: InputManager

    void InputManager()
    {
        if (Input.GetMouseButtonDown(0))
        {
            startClick = Input.mousePosition;
        }
        else if (Input.GetMouseButtonUp(0))
        {
            startClick = -Vector3.one;
        }
        if (Input.GetMouseButton(0))
        {
            selection = new Rect(startClick.x, InvertRectY(startClick.y), Input.mousePosition.x - startClick.x, InvertRectY(Input.mousePosition.y) - InvertRectY(startClick.y));

            if (selection.width < 0)
            {
                Debug.Log("lower width");
                selection.x += selection.width;
                selection.width = -selection.width;
            }
            if (selection.height < 0)
            {
                Debug.Log("lower height");
                selection.y += selection.height;
                selection.height = -selection.height;
            }
        }
    }
开发者ID:Gerigon,项目名称:pTRS,代码行数:28,代码来源:GameManager.cs

示例7: OnGUI

    void OnGUI()
    {
        _guiRect = new Rect(7, Screen.height - 180, 250, 200);
        GUILayout.BeginArea(_guiRect);

        GUILayout.BeginVertical();
        string expName = currentDetonator.name;
        if (GUILayout.Button(expName + " (Click For Next)"))
        {
            NextExplosion();
        }
        if (GUILayout.Button("Rebuild Wall"))
        {
            SpawnWall();
        }
        if (GUILayout.Button("Camera Far"))
        {
            Camera.main.transform.position = new Vector3(0, 0, -7);
            Camera.main.transform.eulerAngles = new Vector3(13.5f, 0, 0);
        }
        if (GUILayout.Button("Camera Near"))
        {
            Camera.main.transform.position = new Vector3(0, -8.664466f, 31.38269f);
            Camera.main.transform.eulerAngles = new Vector3(1.213462f, 0, 0);
        }

        GUILayout.Label("Time Scale");
        timeScale = GUILayout.HorizontalSlider(timeScale, 0.0f, 1.0f);

        GUILayout.Label("Detail Level (re-explode after change)");
        detailLevel = GUILayout.HorizontalSlider(detailLevel, 0.0f, 1.0f);

        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
开发者ID:vonhacker,项目名称:counterstrike,代码行数:35,代码来源:DetonatorTest.cs

示例8: init

    public void init()
    {
        time_texture = Resources.Load("textures/time_gui") as Texture;
        rstats_texture = Resources.Load("textures/rstats_gui") as Texture;

        float w = time_texture.width;
        time_gui_rect = new Rect(0, 0, w, time_texture.height);
        rstats_gui_rect = new Rect(Screen.width - w, 0, w, rstats_texture.height);

        int s_w = Screen.width, s_h = Screen.height;

        debug_rect = new Rect(0, time_texture.height, s_w, (s_h * 2) / 100);
        debug_style.alignment = TextAnchor.UpperLeft;
        debug_style.fontSize = (s_h * 2) / 80;
        debug_style.normal.textColor = new Color(1, 1, 1, 1);

        Font gui_font = Resources.Load("fonts/gui_font") as Font;

        timer_rect = new Rect((time_gui_rect.width / 2.0f) - 125, (time_gui_rect.height / 2.0f) - 40, timer_rect.width, timer_rect.height);
        timer_style.alignment = TextAnchor.UpperLeft;
        timer_style.fontSize = (int)(time_texture.height / 2.0f);
        timer_style.normal.textColor = new Color(1, 1, 1, 1);
        timer_style.font = gui_font;

        rstats_rect = new Rect(rstats_gui_rect.x + ((rstats_gui_rect.width / 2.0f) - 50), (rstats_gui_rect.height / 2.0f) - 40, rstats_rect.width, rstats_rect.height);
        rstats_style.alignment = TextAnchor.UpperLeft;
        rstats_style.fontSize = (rstats_font_size = (int)(rstats_texture.height / 2.0f));
        rstats_style.normal.textColor = new Color(1, 1, 1, 1);
        rstats_style.font = gui_font;
    }
开发者ID:fordream,项目名称:Anglers-Prey,代码行数:30,代码来源:GUI_Manager.cs

示例9: WriteableBitmap

		public WriteableBitmap (UIElement element, Transform transform) :
			base (SafeNativeMethods.writeable_bitmap_new (), true)
		{
			if (element == null)
				throw new ArgumentNullException ("element");

			Rect bounds = new Rect ();
			// Width and Height are defined in FrameworkElement - but it's unlikely to be an "unknown" UIElement
			// descendant since there's no usable ctor to inherit from it (at least outside S.W.dll)
			FrameworkElement fe = (element as FrameworkElement);
			if (fe != null) {
				bounds.Width = fe.ActualWidth;
				bounds.Height = fe.ActualHeight;
			}

			if (transform != null)
				bounds = transform.TransformBounds (bounds);

			AllocatePixels (Double.IsNaN (bounds.Width) ? 0 : (int) bounds.Width, Double.IsNaN (bounds.Height) ? 0 : (int) bounds.Height);
			PinAndSetBitmapData ();

			Invalidate ();

			Render (element, transform);
		}
开发者ID:dfr0,项目名称:moon,代码行数:25,代码来源:WriteableBitmap.cs

示例10: GetBrush

        public static System.Drawing.Brush GetBrush(this Brush brush, Rect frame)
        {
            var cb = brush as SolidBrush;
            if (cb != null) {
                return new System.Drawing.SolidBrush (cb.Color.GetColor ());
            }

            var lgb = brush as LinearGradientBrush;
            if (lgb != null) {
                var s = lgb.Absolute ? lgb.Start : frame.Position + lgb.Start * frame.Size;
                var e = lgb.Absolute ? lgb.End : frame.Position + lgb.End * frame.Size;
                var b = new System.Drawing.Drawing2D.LinearGradientBrush (GetPointF (s), GetPointF (e), System.Drawing.Color.Black, System.Drawing.Color.Black);
                var bb = BuildBlend (lgb.Stops);
                if (bb != null) {
                    b.InterpolationColors = bb;
                }
                return b;
            }

            var rgb = brush as RadialGradientBrush;
            if (rgb != null) {
                var r = rgb.GetAbsoluteRadius (frame);
                var c = rgb.GetAbsoluteCenter (frame);
                var path = new GraphicsPath ();
                path.AddEllipse (GetRectangleF (new Rect (c - r, 2 * r)));
                var b = new PathGradientBrush (path);
                var bb = BuildBlend (rgb.Stops, true);
                if (bb != null) {
                    b.InterpolationColors = bb;
                }
                return b;
            }

            throw new NotImplementedException ("Brush " + brush);
        }
开发者ID:sami1971,项目名称:NGraphics,代码行数:35,代码来源:SystemDrawingPlatform.cs

示例11: OnGUI

    private float vertExtent; // The size of vertical of the screen.

    #endregion Fields

    #region Methods

    void OnGUI()
    {
        float width = Screen.width/4;
        float height = Screen.height/8;

        GUI.skin = _skinNuevo;
        Rect rectBotonNewGame =  new Rect((Screen.width-width)/2,(Screen.height*.25f)-height/2, width,height);
        if (GUI.Button (rectBotonNewGame, "")){
            PlayerPrefsX.SetVector3("CheckSpawn", Vector3.zero);
            PlayerPrefs.SetInt("CountCheck",0);
            PlayerPrefsX.SetVector3 ("OldLevelLight",new Vector3(-12,1,0));
        //			PlayerPrefs.DeleteAll();
        //			Application.LoadLevel("LevelScene");
            Application.LoadLevel("Game");
        }

        GUI.skin = _skinContinuar;
        Rect rectBotonContinuar = new Rect((Screen.width-width)/2,(Screen.height*.50f)-height/2, width,height);

        if (GUI.Button(rectBotonContinuar, "")){
            Application.LoadLevel("CheckLevel");
        }

        GUI.skin = _skinSalir;
        Rect rectBotonSalir = new Rect ((Screen.width-width)/2, (Screen.height*.75f)-height/2, width,height);
        if (GUI.Button (rectBotonSalir, "")) {
            Application.Quit();
        }
    }
开发者ID:GTAPeople,项目名称:Unity-Code-Name-Coma,代码行数:35,代码来源:ScreenMenu.cs

示例12: Start

 void Start()
 {
     this.startButtonRect = new Rect(Screen.width - this.RightMargin - this.StartButtonWidth,
                                     Screen.height - this.BottomMargin - this.StartButtonHeight,
                                     this.StartButtonWidth,
                                     this.StartButtonHeight);
 }
开发者ID:nicharesuk,项目名称:UnityKickstart,代码行数:7,代码来源:TitleScreen.cs

示例13: ResizeMenuHorizontal

	private void ResizeMenuHorizontal(){
		Rect rect = new Rect (listRect.width - 5, listRect.y, 10, listRect.height);
		EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeHorizontal);
		int controlID = GUIUtility.GetControlID(FocusType.Passive);
		Event ev = Event.current;
		switch (ev.rawType) {
		case EventType.MouseDown:
			if(rect.Contains(ev.mousePosition)){
				GUIUtility.hotControl = controlID;
				ev.Use();
			}
			break;
		case EventType.MouseUp:
			if (GUIUtility.hotControl == controlID)
			{
				GUIUtility.hotControl = 0;
				ev.Use();
			}
			break;
		case EventType.MouseDrag:
			if (GUIUtility.hotControl == controlID)
			{
				listRect.width=ev.mousePosition.x;
				listRect.width=Mathf.Clamp(listRect.width,200,400);
				ev.Use();
			}
			break;
		}
	}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:29,代码来源:ListEditor.cs

示例14: changeFrame

    private void changeFrame()
    {
        if(!Loop && !firstRun)
            return;

        newUvs = new Rect(FrameSize*(currentColoum),FrameSize*(currentRow*-1) , 1,1);
        if(changeTexture){
            //EditorDebug.LogWarning("ChangeTExture");
            renderer.material.SetTexture("_MainTex", Textures[currentTexture]);
            changeTexture = false;
        }

        currentColoum++;
        if(currentColoum >= FramesPerRow){
            currentColoum = 0;
            currentRow++;
        }
        if(currentRow >= RowCount)
            currentRow = 0;
        if(currentFrameNumber%FramesPerTexture == 0){
            currentTexture++;
            if(currentTexture >= Textures.Length)
                currentTexture = 0;
            changeTexture = true;
            firstRun = false;

        }
        //EditorDebug.Log("New UVs: " + newUvs + "Row: " + currentRow + "Coloumn: " + currentColoum);
    }
开发者ID:FriedrichWessel,项目名称:Pux_the_Glaciator,代码行数:29,代码来源:AnimatedUVBehaviour.cs

示例15: SetAmmoTo

 private void SetAmmoTo(int newValue)
 {
     int index = 0;
     float width = (newValue * 1f) / ((float) this.userShip.maxProps.ammo);
     if (width >= 0.66f)
     {
         this.ammoSprite.SetSprite(this.progressClipName[2]);
         index = 2;
     }
     else if (width >= 0.33f)
     {
         this.ammoSprite.SetSprite(this.progressClipName[1]);
         index = 1;
     }
     else
     {
         this.ammoSprite.SetSprite(this.progressClipName[0]);
     }
     Rect rect = new Rect(0f, 0f, width, 1f);
     this.ammoSprite.ClipRect = rect;
     if (this.ammoAmountText != null)
     {
         this.ammoAmountText.color = this.textColors[index];
         this.ammoAmountText.text = newValue + "/" + this.userShip.maxProps.ammo;
         this.ammoAmountText.Commit();
     }
 }
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:27,代码来源:ShipInSupply.cs


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