本文整理汇总了C#中UnityEngine.Rect.Scale方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.Scale方法的具体用法?C# Rect.Scale怎么用?C# Rect.Scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Rect
的用法示例。
在下文中一共展示了Rect.Scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(IPlatformDrawer platform, float scale)
{
DrawBackground(platform, scale);
var b = new Rect(Bounds);
b.x += 10;
b.width -= 20;
//base.Draw(platform, scale);
platform.DrawColumns(b.Scale(scale), new float[] { _typeSize.x + 5, _nameSize.x },
_ =>
{
platform.DoButton(_, _cachedTypeName, CachedStyles.ClearItemStyle, OptionClicked, OptionRightClicked);
},
_ =>
{
DrawName(_, platform, scale, DrawingAlignment.MiddleRight);
platform.DoButton(_, "", CachedStyles.ClearItemStyle, () =>
{
if (ItemViewModel.IsSelected)
{
//TODO: Eliminate hack: due to the inconsistent input mechanisms, I cannot fix: when clicking on type, type window appear, then click on the property,
//editing will begin, but type window will stay there. So here is a hack of signaling HideSelection event.
InvertApplication.SignalEvent<IHideSelectionMenu>(__ => __.HideSelection());
ItemViewModel.BeginEditing();
}
else ItemViewModel.Select();
}, OptionRightClicked);
});
}
示例2: Draw
public override void Draw(IPlatformDrawer platform, float scale)
{
base.Draw(platform, scale);
var headerPadding = StyleSchema.HeaderPadding;
// var headerBounds = new Rect(
// Bounds.x - headerPadding.left,
// Bounds.y,
// Bounds.width + headerPadding.left * 2 + 1,
// Bounds.height + (NodeViewModel.IsCollapsed ? 0 : -20) + headerPadding.bottom);
var headerBounds = new Rect(
//Bounds.x-headerPadding.left-1,
Bounds.x-headerPadding.left+1,
Bounds.y+1,
Bounds.width + headerPadding.left + headerPadding.right + headerPadding.left -6,
Bounds.height+0 + (NodeViewModel.IsCollapsed ? 9 : -2));
var image = HeaderImage;
platform.DrawNodeHeader(
headerBounds,
NodeViewModel.IsCollapsed ? StyleSchema.CollapsedHeaderStyleObject : StyleSchema.ExpandedHeaderStyleObject,
NodeViewModel.IsCollapsed,
scale,image);
// The bounds for the main text
// var textBounds = new Rect(Bounds.x, Bounds.y + ((Bounds.height / 2f) - (TextSize.y / 2f)), Bounds.width,
// Bounds.height);
var padding = headerPadding;
var titleBounds = new Rect(
Bounds.x + padding.left,
Bounds.y + padding.top + (StyleSchema.ShowSubtitle ? 1 : 0 ) ,
Bounds.width-padding.right-padding.left-(StyleSchema.ShowIcon ? 16 : 0), //Subtract icon size if shown
Bounds.height-padding.top-padding.bottom);
var titleSize = platform.CalculateTextSize(NodeViewModel.Label, StyleSchema.TitleStyleObject);
var subtitleBound = new Rect(Bounds.x + padding.left+0, Bounds.y + padding.top + titleSize.y + 0, Bounds.width-padding.right, Bounds.height-padding.top);
if (NodeViewModel.IsEditing && NodeViewModel.IsEditable)
{
//UnityEngine.GUI.SetNextControlName("EditingField");
//DiagramDrawer.IsEditingField = true;
//UnityEditor.EditorGUI.BeginChangeCheck();
//var newText = GUI.TextField(textBounds.Scale(scale), NodeViewModel.Name,
// ElementDesignerStyles.ViewModelHeaderEditingStyle);
//if (UnityEditor.EditorGUI.EndChangeCheck())
//{
// NodeViewModel.Rename(newText);
// Dirty = true;
//}
//textBounds.y += TextSize.y / 2f;
platform.DrawTextbox(NodeViewModel.GraphItemObject.Identifier, titleBounds.Scale(scale), NodeViewModel.Name, CachedStyles.ViewModelHeaderStyle, (v, finished) =>
{
NodeViewModel.Rename(v);
ParentDrawer.Refresh(platform);
if (finished)
{
NodeViewModel.EndEditing();
}
});
}
else
{
//var titleStyle = new GUIStyle(TextStyle);
//titleStyle.normal.textColor = BackgroundStyle.normal.textColor;
//titleStyle.alignment = TextAnchor.MiddleCenter;
//titleStyle.fontSize = Mathf.RoundToInt(12*scale);
platform.DrawLabel(titleBounds.Scale(scale), NodeViewModel.Label ?? string.Empty, StyleSchema.TitleStyleObject, StyleSchema.ShowSubtitle ? DrawingAlignment.TopLeft : DrawingAlignment.MiddleLeft);
if (StyleSchema.ShowSubtitle && !string.IsNullOrEmpty(NodeViewModel.SubTitle))
{
platform.DrawLabel(subtitleBound.Scale(scale), NodeViewModel.SubTitle ?? string.Empty,
StyleSchema.SubTitleStyleObject, StyleSchema.ShowSubtitle ? DrawingAlignment.TopLeft : DrawingAlignment.MiddleLeft);
}
if (StyleSchema.ShowIcon && !string.IsNullOrEmpty(NodeViewModel.IconName))
{
var iconsize = IconBounds ?? (IconBounds = new Vector2(16,16));
var size = 16;
var imageBounds = new Rect(Bounds.xMax - padding.right - size, Bounds.y + ((Bounds.height / 2f) - (size / 2f)), 16, 16);
//var imageBounds = new Rect().WithSize(16, 16).InnerAlignWithUpperRight(Bounds).AlignHorisonallyByCenter(headerBounds).Translate(-headerPadding.right,0);
var cCache = GUI.color;
GUI.color = new Color(cCache.r, cCache.g, cCache.b, 0.7f);
platform.DrawImage(imageBounds.Scale(scale), IconImage, true);
GUI.color = cCache;
if (!string.IsNullOrEmpty(IconTooltip))
//.........这里部分代码省略.........