本文整理汇总了C#中Rect.Trim方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.Trim方法的具体用法?C# Rect.Trim怎么用?C# Rect.Trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect.Trim方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScreenOverscan
public static Rect ScreenOverscan(Rect normalized, float overscan) {
float ratio = Mathf.Clamp(overscan, 0, .05f);
Rect overScreen = new Rect(0, 0, Screen.width, Screen.height);
overScreen = overScreen.Trim(ratio * Screen.width, ratio * Screen.height);
return new Rect(overScreen.x + overScreen.width * normalized.x,
overScreen.y + overScreen.height * normalized.y,
overScreen.width * normalized.width,
overScreen.height * normalized.height);
}
示例2: Draw
public static void Draw(Rect area, float pp, Color tint, Color back, int padding) {
Rect brush = area.Trim(-padding);
float p = Mathf.Clamp01(pp);
Texture2D g = GetGraphic(area);
GUI.color = back;
GUI.DrawTexture(brush, g);
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 = tint;
GUI.DrawTexture(brush, g);
}