本文整理汇总了C#中UnityEngine.RectOffset类的典型用法代码示例。如果您正苦于以下问题:C# RectOffset类的具体用法?C# RectOffset怎么用?C# RectOffset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RectOffset类属于UnityEngine命名空间,在下文中一共展示了RectOffset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GUILayoutGroup
public GUILayoutGroup(GUIStyle _style, GUILayoutOption[] options) : base(0f, 0f, 0f, 0f, _style)
{
this.entries = new List<GUILayoutEntry>();
this.isVertical = true;
this.resetCoords = false;
this.spacing = 0f;
this.sameSize = true;
this.isWindow = false;
this.windowID = -1;
this.m_Cursor = 0;
this.m_StretchableCountX = 100;
this.m_StretchableCountY = 100;
this.m_UserSpecifiedWidth = false;
this.m_UserSpecifiedHeight = false;
this.m_ChildMinWidth = 100f;
this.m_ChildMaxWidth = 100f;
this.m_ChildMinHeight = 100f;
this.m_ChildMaxHeight = 100f;
this.m_Margin = new RectOffset();
if (options != null)
{
this.ApplyOptions(options);
}
this.m_Margin.left = _style.margin.left;
this.m_Margin.right = _style.margin.right;
this.m_Margin.top = _style.margin.top;
this.m_Margin.bottom = _style.margin.bottom;
}
示例2: UpdateBar
private void UpdateBar()
{
/*
* Calculate offset of bar texture based on percent points.
*/
percentage = Mathf.Clamp (percentage, -100, 100);
RectOffset tempOffset = new RectOffset(0, 0, -(percentage*edges)/100, 0);
if(percentage > 0)
{
happyBar.border = tempOffset;
sadBar.border = new RectOffset(0, 0, 0, 0);
}
else
{
happyBar.border = new RectOffset(0, 0, 0, 0);
sadBar.border = tempOffset;
}
CheckGlow();
if(percentage <= -99)
{
gameOverScript.TriggerGameOver();
}
}
示例3: OnGUI
void OnGUI()
{
GUIStyle myStyle = new GUIStyle (GUI.skin.box);
myStyle.normal.textColor = Color.white;
myStyle.onNormal.textColor = Color.white;
myStyle.onHover.textColor = Color.white;
myStyle.alignment = TextAnchor.MiddleCenter;
RectOffset margin = new RectOffset ();
margin.bottom = 10;
margin.top = 10;
myStyle.margin = margin;
int ftSize = (int)(Screen.height * .07);
myStyle.fontSize = ftSize;
if (GUI.Button (new Rect (Screen.width * .25f, Screen.height * .30f, Screen.width * .5f, Screen.height * .1f), "New Game", myStyle)) {
}
if (GUI.Button (new Rect (Screen.width * .25f, Screen.height * .42f, Screen.width * .5f, Screen.height * .1f), "Leaderboard", myStyle)) {
Application.LoadLevel (1);
}
if (GUI.Button (new Rect (Screen.width * .25f, Screen.height * .66f, Screen.width * .5f, Screen.height * .1f), "Quit", myStyle)) {
Application.Quit();
}
}
示例4: Awake
public override void Awake()
{
size = new Vector2(400, 100);
anchor = UIAnchorStyle.Bottom & UIAnchorStyle.Left;
backgroundSprite = "ButtonMenu";
autoLayoutPadding = new RectOffset(10, 10, 4, 4);
autoLayout = true;
autoFitChildrenVertically = true;
autoLayoutDirection = LayoutDirection.Vertical;
timeOfDay = AddUIComponent<UILabel>();
timeOfDay.textAlignment = UIHorizontalAlignment.Center;
timeOfDay.size = new Vector2(width - 20, 20);
timeOfDay.autoSize = false;
timeSlider = UIFactory.CreateSlider(this, 0.0f, 24.0f);
timeSlider.stepSize = 1f / 60.0f;
timeSlider.eventValueChanged += ChangeTime;
((UIPanel)timeSlider.parent).backgroundSprite = "BudgetBarBackground";
((UISprite)timeSlider.thumbObject).spriteName = "InfoIconBasePressed";
timeSlider.eventDragStart += timeSlider_eventDragStart;
//timeSlider.eventDragEnd += timeSlider_eventDragEnd;
eventMouseUp += timeSlider_eventDragEnd;
UISprite pad = AddUIComponent<UISprite>();
pad.autoSize = false;
pad.size = new Vector2(10, 5);
}
示例5: SkinBG
public SkinBG(Texture2D bgTex, RectOffset b)
{
size = new Vector2(bgTex.width, bgTex.height);
border = b;
if(border.left > 0)
{
// bottom left
this.bl = TextureDrawer.GetSecuredPixels(bgTex, 0, 0, border.left, border.bottom);
// left center
this.cl = TextureDrawer.GetSecuredPixels(bgTex, 0, border.bottom, border.left, bgTex.height-border.vertical);
// top left
this.tl =TextureDrawer.GetSecuredPixels(bgTex, 0, bgTex.height-border.top, border.left, border.top);
}
// bottom center
this.bc = TextureDrawer.GetSecuredPixels(bgTex, border.left, 0, bgTex.width-border.horizontal, border.bottom);
// center center
this.cc = TextureDrawer.GetSecuredPixels(bgTex, border.left, border.bottom, bgTex.width-border.horizontal, bgTex.height-border.vertical);
// top center
this.tc = TextureDrawer.GetSecuredPixels(bgTex, border.left, bgTex.height-border.top, bgTex.width-border.horizontal, border.top);
if(border.right > 0)
{
// bottom right
this.br = TextureDrawer.GetSecuredPixels(bgTex, bgTex.width-border.right, 0, border.right, border.bottom);
// right center
this.cr = TextureDrawer.GetSecuredPixels(bgTex, bgTex.width-border.right, border.bottom, border.right, bgTex.height-border.vertical);
// top right
this.tr = TextureDrawer.GetSecuredPixels(bgTex, bgTex.width-border.right, bgTex.height-border.top, border.right, border.top);
}
}
示例6: constructor
public static int constructor(IntPtr l)
{
try {
int argc = LuaDLL.lua_gettop(l);
UnityEngine.RectOffset o;
if(argc==1){
o=new UnityEngine.RectOffset();
pushValue(l,true);
pushValue(l,o);
return 2;
}
else if(argc==5){
System.Int32 a1;
checkType(l,2,out a1);
System.Int32 a2;
checkType(l,3,out a2);
System.Int32 a3;
checkType(l,4,out a3);
System.Int32 a4;
checkType(l,5,out a4);
o=new UnityEngine.RectOffset(a1,a2,a3,a4);
pushValue(l,true);
pushValue(l,o);
return 2;
}
return error(l,"New object failed.");
}
catch(Exception e) {
return error(l,e);
}
}
示例7: SetRectOffset
public static RectOffset SetRectOffset(RectOffset tmpRectOffset, int Left, int Right, int Top, int Bottom)
{
tmpRectOffset.left = Left;
tmpRectOffset.top = Top;
tmpRectOffset.right = Right;
tmpRectOffset.bottom = Bottom;
return tmpRectOffset;
}
示例8: OnPreviewGUI
public override void OnPreviewGUI(Rect r, GUIStyle background)
{
if (Event.current.type != EventType.Repaint)
return;
if (m_Styles == null)
m_Styles = new Styles();
GameObject go = target as GameObject;
RectTransform rect = go.transform as RectTransform;
if (rect == null)
return;
// Apply padding
RectOffset previewPadding = new RectOffset(-5, -5, -5, -5);
r = previewPadding.Add(r);
// Prepare rects for columns
r.height = EditorGUIUtility.singleLineHeight;
Rect labelRect = r;
Rect valueRect = r;
Rect sourceRect = r;
labelRect.width = kLabelWidth;
valueRect.xMin += kLabelWidth;
valueRect.width = kValueWidth;
sourceRect.xMin += kLabelWidth + kValueWidth;
// Headers
GUI.Label(labelRect, "Property", m_Styles.headerStyle);
GUI.Label(valueRect, "Value", m_Styles.headerStyle);
GUI.Label(sourceRect, "Source", m_Styles.headerStyle);
labelRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
valueRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
sourceRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
// Prepare reusable variable for out argument
ILayoutElement source = null;
// Show properties
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Width", LayoutUtility.GetLayoutProperty(rect, e => e.minWidth, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Height", LayoutUtility.GetLayoutProperty(rect, e => e.minHeight, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Width", LayoutUtility.GetLayoutProperty(rect, e => e.preferredWidth, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Height", LayoutUtility.GetLayoutProperty(rect, e => e.preferredHeight, 0, out source).ToString(), source);
float flexible = 0;
flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleWidth, 0, out source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Width", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source);
flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleHeight, 0, out source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Height", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source);
if (!rect.GetComponent<LayoutElement>())
{
Rect noteRect = new Rect(labelRect.x, labelRect.y + 10, r.width, EditorGUIUtility.singleLineHeight);
GUI.Label(noteRect, "Add a LayoutElement to override values.", m_Styles.labelStyle);
}
}
示例9: Awake
public override void Awake()
{
autoFitChildrenVertically = true;
backgroundSprite = "MenuPanel";
width = 200;
height = 400;
anchor = UIAnchorStyle.Top | UIAnchorStyle.Left;
m_AutoLayoutPadding = new RectOffset(5, 5, 5, 0);
m_AutoLayoutDirection = LayoutDirection.Vertical;
m_AutoLayout = true;
title = AddUIComponent<UILabel>();
title.autoSize = false;
title.textScale = 1.1f;
title.verticalAlignment = UIVerticalAlignment.Middle;
title.textAlignment = UIHorizontalAlignment.Center;
title.size = new Vector2(width - 10, 40);
chart = AddUIComponent<BreakdownPercent>();
chart.size = new Vector2(190, 190);
chart.spriteName = "PieChartWhiteBg";
breakdown = new BreakdownElement[20];
for(int i = 0; i < breakdown.Length; i++)
{
BreakdownElement view = AddUIComponent<BreakdownElement>();
view.tooltip = "Click to toggle display";
view.size = new Vector2(200, 15);
view.eventMouseEnter += (UIComponent component, UIMouseEventParameter eventParam) =>
{
if (eventHighlightType != null)
eventHighlightType(view.type);
};
view.eventMouseLeave += (UIComponent component, UIMouseEventParameter eventParam) =>
{
if (eventHighlightType != null)
eventHighlightType(null);
};
breakdown[i] = view;
}
total = AddUIComponent<UILabel>();
total.autoSize = false;
total.text = "Total: 0";
total.textColor = new Color32(206, 248, 0, 255);
total.textScale = 0.9f;
total.verticalAlignment = UIVerticalAlignment.Middle;
total.size = new Vector2(190, 35);
Invalidate();
}
示例10: DrawOptionData
private void DrawOptionData(Rect rect, int index, bool isActive, bool isFocused)
{
SerializedProperty arrayElementAtIndex = this.m_ReorderableList.serializedProperty.GetArrayElementAtIndex(index);
SerializedProperty propertyRelative1 = arrayElementAtIndex.FindPropertyRelative("m_Text");
SerializedProperty propertyRelative2 = arrayElementAtIndex.FindPropertyRelative("m_Image");
rect = new RectOffset(0, 0, -1, -3).Add(rect);
rect.height = EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, propertyRelative1, GUIContent.none);
rect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, propertyRelative2, GUIContent.none);
}
示例11: Awake
protected override void Awake()
{
WindowCaption = "S.C.A.N. Instruments";
WindowRect = sessionRect;
WindowStyle = SCANskins.SCAN_window;
WindowOptions = new GUILayoutOption[2] { GUILayout.Width(260), GUILayout.Height(60) };
Visible = false;
DragEnabled = true;
ClampToScreenOffset = new RectOffset(-200, -200, -40, -40);
SCAN_SkinsLibrary.SetCurrent("SCAN_Unity");
}
示例12: Awake
protected override void Awake()
{
WindowCaption = "S.C.A.N. Planetary Mapping";
WindowRect = sessionRect;
WindowOptions = new GUILayoutOption[2] { GUILayout.Width(380), GUILayout.Height(230) };
WindowStyle = SCANskins.SCAN_window;
Visible = false;
DragEnabled = true;
TooltipMouseOffset = new Vector2d(-10, -25);
ClampToScreenOffset = new RectOffset(-300, -300, -200, -200);
SCAN_SkinsLibrary.SetCurrent("SCAN_Unity");
SCAN_SkinsLibrary.SetCurrentTooltip();
}
示例13: Horizontal
/// <summary>
/// Shows the given block delegate using an horizontal layout.
/// </summary>
/// <example><code>HOGUILayout.Horizontal(myGUIStyle, () => { block code here; };</code></example>
public static void Horizontal(RectOffset padding, GUIStyle guiStyle, Color backgroundShade, Action blockAction, params GUILayoutOption[] options)
{
GUIStyle style;
if (padding != null) {
style = guiStyle == null ? new GUIStyle() : new GUIStyle(guiStyle);
style.padding.left += padding.left;
style.padding.right += padding.right;
style.padding.top += padding.top;
style.padding.bottom += padding.bottom;
} else {
style = guiStyle;
}
_Horizontal(style, backgroundShade, blockAction, options);
}
示例14: Awake
protected override void Awake()
{
WindowCaption = "S.C.A.N. Color Management";
WindowRect = sessionRect;
WindowStyle = SCANskins.SCAN_window;
WindowOptions = new GUILayoutOption[2] { GUILayout.Width(780), GUILayout.Height(360) };
Visible = false;
DragEnabled = true;
ClampToScreenOffset = new RectOffset(-450, -450, -250, -250);
SCAN_SkinsLibrary.SetCurrent("SCAN_Unity");
removeControlLocks();
}
示例15: DrawOptionData
private void DrawOptionData(Rect rect, int index, bool isActive, bool isFocused)
{
SerializedProperty itemData = m_ReorderableList.serializedProperty.GetArrayElementAtIndex(index);
SerializedProperty itemText = itemData.FindPropertyRelative("m_Text");
SerializedProperty itemImage = itemData.FindPropertyRelative("m_Image");
RectOffset offset = new RectOffset(0, 0, -1, -3);
rect = offset.Add(rect);
rect.height = EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, itemText, GUIContent.none);
rect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, itemImage, GUIContent.none);
}