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


C# Rect.Pad方法代码示例

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


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

示例1: Draw

	public static void Draw(Rect area, Rect repeat, float pp, Color tint, Color back, int padding) {
		Rect brush = area.Pad(padding);
		float p = Mathf.Clamp01(pp);
		Texture2D g = GetGraphic(area);
		
		GUI.color = back;
		GUI.DrawTextureWithTexCoords(brush, g, repeat);
		brush = brush.Trim(padding);
		
		Rect filled = brush;
		Rect filledReps = repeat;
		Rect empty = brush;
		Rect emptyReps = repeat;
		
		if (area.width > area.height) {
			filled = filled.UpperLeft(p, 1);
			filledReps = filledReps.UpperLeft(p, 1);
			empty = empty.UpperRight(1.0f-p, 1);
			emptyReps = emptyReps.UpperRight(1.0f-p, 1);
		} else {
			filled = filled.BottomLeft(1, p);
			filledReps = filledReps.UpperLeft(1, p);
			empty = empty.UpperLeft(1, 1.0f-p);
			emptyReps = emptyReps.BottomLeft(1, 1.0f-p);
		}
		
		GUI.color = tint;
		GUI.DrawTextureWithTexCoords(filled, g, filledReps);
		GUI.color = back;
		GUI.DrawTextureWithTexCoords(empty, g, emptyReps);
	}
开发者ID:wfowler1,项目名称:Miscellaneous-Soundboards,代码行数:31,代码来源:Bars.cs

示例2: OnGUI

	void OnGUI() {
		if (hidden) { val = Vector2.zero; return; }
		overzone = (int) (Screen.height * overzoneRatio);
		padding = (int) (Screen.height * paddingRatio);
		
		pixelSize = size * Screen.height;
		pixelCenter = new Vector2(position.x * Screen.width, position.y * Screen.height);
		pixelPosition = pixelCenter - (Vector2.one * pixelSize/2.0f);
		
		Rect insideBrush = new Rect(pixelPosition.x, pixelPosition.y, pixelSize, pixelSize);
		Rect outsideBrush = insideBrush.Pad(padding/2.0f);
		Rect perimBrush = outsideBrush.Pad(overzone/2.0f);
		
		GUI.color = perimColor;
		GUI.DrawTexture(perimBrush, perimGraphic);
		
		GUI.color = backColor;
		GUI.DrawTexture(outsideBrush, backGraphic);
		
		Vector2 difference;
		Vector2 realTouchPosition;
		bool hasHadGoodTouch = false;
		
		foreach (Touch t in Input.touches) {
			realTouchPosition = t.position;
			realTouchPosition.y = Screen.height - realTouchPosition.y;
			
			difference = pixelCenter - realTouchPosition;
			if (difference.magnitude < pixelSize + overzone) {
				if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled) { continue; }
				
				hasHadGoodTouch = true;
				val = -difference.normalized * Mathf.Min(1, (difference.magnitude / pixelSize));
				if (lockXaxis) { val.x = 0; }
				if (lockYaxis) { val.y = 0; }
				val.Normalize();
				
				break;
			}
			
			
		}
		
		
		if (!hasHadGoodTouch) { val = Vector2.zero; }
		insideBrush.x += value.x * pixelSize;
		insideBrush.y += value.y * pixelSize;
		
		if (invertXout) { val.x *= -1; }
		if (invertYout) { val.y *= -1; }
		
		GUI.color = mainColor;
		GUI.DrawTexture(insideBrush, mainGraphic);
	
		
	}
开发者ID:wfowler1,项目名称:Miscellaneous-Soundboards,代码行数:56,代码来源:SimulatedControlStick.cs

示例3: DrawRepeat

	public void DrawRepeat(Rect area, float fill) {
		Rect brush = area.Pad(padding);
		float p = Mathf.Clamp01(fill);
		
		
		GUI.color = backColor;
		GUI.DrawTextureWithTexCoords(brush, backGraphic, repeat);
		brush = brush.Trim(padding);
		
		Rect filled = brush;
		Rect filledReps = repeat;
		Rect empty = brush;
		Rect emptyReps = repeat;
		
		if (area.width > area.height) {
			filled = filled.UpperLeft(p, 1);
			filledReps = filledReps.UpperLeft(p, 1);
			empty = empty.UpperRight(1.0f-p, 1);
			emptyReps = emptyReps.UpperRight(1.0f-p, 1);
		} else {
			filled = filled.BottomLeft(1, p);
			filledReps = filledReps.UpperLeft(1, p);
			empty = empty.UpperLeft(1, 1.0f-p);
			emptyReps = emptyReps.BottomLeft(1, 1.0f-p);
		}
		
		GUI.color = backColor;
		GUI.DrawTextureWithTexCoords(empty, backGraphic, emptyReps);
		GUI.color = frontColor;
		GUI.DrawTextureWithTexCoords(filled, frontGraphic, filledReps);
	}
开发者ID:wfowler1,项目名称:Miscellaneous-Soundboards,代码行数:31,代码来源:Bar.cs

示例4: DrawNormal

	public void DrawNormal(Rect area, float fill) {
		Rect brush = area.Pad(padding);
		float p = Mathf.Clamp01(fill);
		
		GUI.color = backColor;
		GUI.DrawTexture(brush, backGraphic);
		
		brush = brush.Trim(padding);
		if (area.width > area.height) { brush.width *= p; }
		else { 
			brush.y += area.height * (1.0f - p);
			brush.height *= p;
		}
		GUI.color = frontColor;
		GUI.DrawTexture(brush, frontGraphic);
	}
开发者ID:wfowler1,项目名称:Miscellaneous-Soundboards,代码行数:16,代码来源:Bar.cs

示例5: OnGUI

	void OnGUI() {
		GUI.skin = skin;
		GUI.depth = depth;
		
		Color c = sets.color;
		c.a = time / sets.fadeTime;
		GUI.color = c;
		
		GUIStyle style = GUI.skin.label.FontSize(fontSize);
		
		Vector2 size = style.CalcSize(new GUIContent(message));
		//Vector2 size = new Vector2(1, 1);
		//size.x += GUI.skin.box.padding.left + GUI.skin.box.padding.right + 2;
		//size.y += GUI.skin.box.padding.top + GUI.skin.box.padding.bottom + 2;
		//position -= size * .5f;
		
		//Debug.Log(size);
		
		/*
		size.x /= Screen.width;
		size.y /= Screen.height;
		Rect area = new Rect(position.x, position.y, size.x, size.y);
		area.x -= size.x *.5f;
		area.y -= size.y *.5f;
		msg.Draw(area);
		//*/
		
		//*
		Rect area = new Rect(position.x * Screen.width, position.y * Screen.height, size.x, size.y);
		area = area.Pad(4.0f);
		area = area.Move(-.5f, -.5f);
		
		if (outlined) {
			GUIF.Label(area, message, style);
		} else {
			GUI.Label(area, message, style);
		}
		//*/
	}
开发者ID:wfowler1,项目名称:Miscellaneous-Soundboards,代码行数:39,代码来源:GUIMessage.cs

示例6: DrawActionsExplorer

    public  void DrawActionsExplorer(Rect obj)
    {
        if(ActionsViewModel.IsDirty) ActionsViewModel.Refresh();

        var mainContentBounds = obj.Pad(0, 0, 0, 30);
        var listRect = mainContentBounds.LeftHalf();
        var actionCode = mainContentBounds.RightHalf().BottomHalf();

        Signal<IDrawTreeView>(_=>_.DrawTreeView(listRect.PadSides(15),ActionsViewModel,(m,i)=>{}));
        
        
        //var selectedAction = ActionsViewModel.SelectedData as ActionNode;

        var item = ActionsViewModel.SelectedData;
        if (item != null)
        {
            PlatformDrawer.DrawStretchBox(actionCode, CachedStyles.WizardSubBoxStyle, 15);
            PlatformDrawer.DrawLabel(actionCode.PadSides(15),
                string.Format("Title: {0}\nType: {1}\n", item.Title, item.GetType().Name)
                , CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.TopLeft);
        }
        var updateButton = new Rect().WithSize(80, 24).InnerAlignWithBottomLeft(obj);
        
        
        
        PlatformDrawer.DoButton(updateButton,"Update",ElementDesignerStyles.ButtonStyle, () =>
        {
            EditorApplication.delayCall += () =>
            {
                ActionsViewModel = null;
                DataItems = null;
            };
        });


        PlatformDrawer.DrawTextbox("12345", new Rect().WithSize(120, 24).Align(updateButton).RightOf(updateButton), _searchCriterial, GUI.skin.textField,
            (a,b) =>
            {
                if( _searchCriterial == a) return;
                _searchCriterial = a;

                if (!string.IsNullOrEmpty(_searchCriterial))
                {
                    ActionsViewModel.Predicate = i =>
                    {
                        if (string.IsNullOrEmpty(i.Title)) return false;

                        if (
                            CultureInfo.CurrentCulture.CompareInfo.IndexOf(i.Title, _searchCriterial,
                                CompareOptions.IgnoreCase) != -1) return true;

                        if (!string.IsNullOrEmpty(i.SearchTag) &&
                            CultureInfo.CurrentCulture.CompareInfo.IndexOf(i.SearchTag, _searchCriterial,
                                CompareOptions.IgnoreCase) != -1) return true;

                        return false;
                    };
                }
                else
                {
                    ActionsViewModel.Predicate = null;
                }
                ActionsViewModel.IsDirty = true;
            });

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


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