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


C# RectOffset.Add方法代码示例

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


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

示例1: 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);
            }
        }
开发者ID:gdzzzyyy,项目名称:UGUIlok,代码行数:58,代码来源:LayoutPropertiesPreview.cs

示例2: 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);
        }
开发者ID:gdzzzyyy,项目名称:UGUIlok,代码行数:14,代码来源:DropdownOptionListDrawer.cs

示例3: OnGUI

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty code = property.FindPropertyRelative("m_Glyph.m_Unicode");
            SerializedProperty name = property.FindPropertyRelative("m_Glyph.m_Name");
            SerializedProperty font = property.FindPropertyRelative("m_Font");
            GUIStyle iconStyle = new GUIStyle { font = (Font)font.objectReferenceValue, fontSize = 16 };

            RectOffset offset = new RectOffset(0, 0, -1, -3);
            position = offset.Add(position);
            position.height = EditorGUIUtility.singleLineHeight;

            float offsetH = 0;

            offsetH -= EditorGUI.PrefixLabel(new Rect(position.x + offsetH, position.y, 40, position.height), label).width;

            offsetH += 40;

            if (!string.IsNullOrEmpty(name.stringValue))
            {
                GUIContent iconLabel = new GUIContent(IconDecoder.Decode(code.stringValue));
                EditorGUI.LabelField(new Rect(position.x + offsetH, position.y, 16, position.height), iconLabel, iconStyle);

                float iconWidth = iconStyle.CalcSize(iconLabel).x;
                offsetH += iconWidth + 2f;

                EditorGUI.LabelField(new Rect(position.x + offsetH, position.y, position.width - offsetH - 80, position.height), name.stringValue);
            }
            else
            {
                EditorGUI.LabelField(new Rect(position.x + offsetH, position.y, position.width - 70 - 56, position.height), "No icon selected");
            }

            if (GUI.Button(new Rect(position.width - 74, position.y, 70, position.height), "Pick Icon"))
            {
                VectorImagePickerWindow.Show((VectorImageData)fieldInfo.GetValue(property.serializedObject.targetObject), property.serializedObject.targetObject);
            }
            if (GUI.Button(new Rect(position.width - 2, position.y, 18, position.height), IconDecoder.Decode(@"\ue14c"), new GUIStyle { font = VectorImageManager.GetIconFont(VectorImageManager.materialDesignIconsFontName) }))
            {
                VectorImageData data = ((VectorImageData)fieldInfo.GetValue(property.serializedObject.targetObject));
                data.font = null;
                data.glyph = null;
                EditorUtility.SetDirty(property.serializedObject.targetObject);
            }
        }
开发者ID:adamtelfer,项目名称:idlecraft,代码行数:44,代码来源:VectorImageDataPropertyDrawer.cs

示例4: OnPreviewGUI

        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type != EventType.Repaint)
                return;

            if (m_Styles == null)
                m_Styles = new Styles();

            Vector2 maxEventLabelSize = Vector2.zero;
            int totalInterceptedEvents = 0;

            ComponentInterceptedEvents[] componentIncerceptedEvents = m_TargetEvents[target as GameObject];

            // Find out the maximum size needed for any given label.
            foreach (ComponentInterceptedEvents componentInterceptedEvents in componentIncerceptedEvents)
            {
                foreach (GUIContent eventContent in componentInterceptedEvents.interceptedEvents)
                {
                    ++totalInterceptedEvents;
                    Vector2 labelSize = m_Styles.labelStyle.CalcSize(eventContent);
                    if (maxEventLabelSize.x < labelSize.x)
                    {
                        maxEventLabelSize.x = labelSize.x;
                    }
                    if (maxEventLabelSize.y < labelSize.y)
                    {
                        maxEventLabelSize.y = labelSize.y;
                    }
                }
            }

            // Apply padding
            RectOffset previewPadding = new RectOffset(-5, -5, -5, -5);
            r = previewPadding.Add(r);

            // Figure out how many rows and columns we can/should have
            int columns = Mathf.Max(Mathf.FloorToInt(r.width / maxEventLabelSize.x), 1);
            int rows = Mathf.Max(totalInterceptedEvents / columns, 1) + componentIncerceptedEvents.Length;

            // Centering
            float initialX = r.x + Mathf.Max(0, (r.width - (maxEventLabelSize.x * columns)) / 2);
            float initialY = r.y + Mathf.Max(0, (r.height - (maxEventLabelSize.y * rows)) / 2);

            Rect labelRect = new Rect(initialX, initialY, maxEventLabelSize.x, maxEventLabelSize.y);
            int currentColumn = 0;
            foreach (ComponentInterceptedEvents componentInterceptedEvents in componentIncerceptedEvents)
            {
                GUI.Label(labelRect, componentInterceptedEvents.componentName, m_Styles.componentName);
                labelRect.y += labelRect.height;
                labelRect.x = initialX;
                foreach (GUIContent eventContent in componentInterceptedEvents.interceptedEvents)
                {
                    GUI.Label(labelRect, eventContent, m_Styles.labelStyle);
                    if (currentColumn < columns - 1)
                    {
                        labelRect.x += labelRect.width;
                    }
                    else
                    {
                        labelRect.y += labelRect.height;
                        labelRect.x = initialX;
                    }

                    currentColumn = (currentColumn + 1) % columns;
                }

                if (labelRect.x != initialX)
                {
                    labelRect.y += labelRect.height;
                    labelRect.x = initialX;
                }
            }
        }
开发者ID:602147629,项目名称:Unity-ugui,代码行数:73,代码来源:InterceptedEventsPreview.cs

示例5: WorldOrigin

 public static Vector3 WorldOrigin(Camera camera, UIAnchor.Side side, RectOffset offset, bool halfPixel)
 {
     Vector3 vector3 = new Vector3();
     UIAnchor.Flags flag;
     vector3.z = 0f;
     Rect rect = offset.Add(camera.pixelRect);
     float single = rect.xMin;
     float single1 = rect.xMax;
     float single2 = rect.yMin;
     float single3 = rect.yMax;
     UIAnchor.Side side1 = side;
     float single4 = single;
     float single5 = single1;
     float single6 = single2;
     float single7 = single3;
     if (camera.isOrthoGraphic)
     {
         flag = (!halfPixel ? UIAnchor.Flags.CameraIsOrthographic : UIAnchor.Flags.CameraIsOrthographic | UIAnchor.Flags.HalfPixelOffset);
     }
     else if (!halfPixel)
     {
         flag = (UIAnchor.Flags)0;
     }
     else
     {
         flag = UIAnchor.Flags.HalfPixelOffset;
     }
     UIAnchor.ScreenOrigin(side1, single4, single5, single6, single7, flag, out vector3.x, out vector3.y);
     return camera.ScreenToWorldPoint(vector3);
 }
开发者ID:HexHash,项目名称:LegacyRust,代码行数:30,代码来源:UIAnchor.cs

示例6: ShowOverlay

 public override void ShowOverlay()
 {
     if (this.HasSelectedinstruction())
     {
         IMGUILayoutInstruction instruction = this.m_LayoutInstructions[base.m_ListViewState.row];
         RectOffset offset = new RectOffset {
             left = instruction.marginLeft,
             right = instruction.marginRight,
             top = instruction.marginTop,
             bottom = instruction.marginBottom
         };
         this.m_FakeMargingStyleForOverlay.padding = offset;
         Rect unclippedRect = instruction.unclippedRect;
         unclippedRect = offset.Add(unclippedRect);
         base.m_GuiViewDebuggerWindow.HighlightInstruction(base.m_GuiViewDebuggerWindow.m_Inspected, unclippedRect, this.m_FakeMargingStyleForOverlay);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:17,代码来源:GUILayoutInspectView.cs

示例7: 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 itemSprite = itemData.FindPropertyRelative("m_ImageData.m_Sprite");

			SerializedProperty itemCode = itemData.FindPropertyRelative("m_ImageData.m_VectorImageData.m_Glyph.m_Unicode");
            SerializedProperty itemName = itemData.FindPropertyRelative("m_ImageData.m_VectorImageData.m_Glyph.m_Name");
            GUIStyle iconStyle = new GUIStyle { font = (Font)itemData.FindPropertyRelative("m_ImageData.m_VectorImageData.m_Font").objectReferenceValue };

            SerializedProperty itemImageType = itemData.FindPropertyRelative("m_ImageData.m_ImageDataType");

            RectOffset offset = new RectOffset(0, 0, -1, -3);
            rect = offset.Add(rect);
            rect.height = EditorGUIUtility.singleLineHeight;

            float offsetH = 0;

            EditorGUI.LabelField(new Rect(rect.x, rect.y, 16, rect.height), index.ToString());
            offsetH += 16;

			EditorGUI.LabelField(new Rect(rect.x + offsetH, rect.y, 35, rect.height), "Text", EditorStyles.boldLabel);
            offsetH += 35;

            EditorGUI.PropertyField(new Rect(rect.x + offsetH, rect.y, (rect.width / 3) - offsetH, rect.height), itemText, GUIContent.none);
            offsetH += (rect.width / 3) - offsetH + 8;

			EditorGUI.LabelField(new Rect(rect.x + offsetH, rect.y, 32, rect.height), "Icon", EditorStyles.boldLabel);
            offsetH += 32;

            itemImageType.enumValueIndex = m_ImageType.enumValueIndex;

            if (m_ImageType.enumValueIndex == 0)
            {
                EditorGUI.PropertyField(new Rect(rect.x + offsetH, rect.y, rect.width - offsetH, rect.height), itemSprite, GUIContent.none);
            }
            else
            {
                if (!string.IsNullOrEmpty(itemName.stringValue))
                {
                    EditorGUI.LabelField(new Rect(rect.x + offsetH, rect.y, 16, rect.height), IconDecoder.Decode(itemCode.stringValue), iconStyle);
                    offsetH += 16;
                    EditorGUI.LabelField(new Rect(rect.x + offsetH, rect.y, rect.width - offsetH - 80, rect.height), itemName.stringValue);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(rect.x + offsetH, rect.y, rect.width - offsetH - 80, rect.height), "No icon selected");
                }

                if (GUI.Button(new Rect(rect.width - 60, rect.y, 70, rect.height), "Pick Icon"))
                {

                    IOptionDataListContainer optionDataListContainer = itemData.serializedObject.targetObject as IOptionDataListContainer;
                    VectorImagePickerWindow.Show(optionDataListContainer.optionDataList.options[index].imageData.vectorImageData, itemData.serializedObject.targetObject);

                }

                if (GUI.Button(new Rect(rect.width + 16, rect.y, 18, rect.height), IconDecoder.Decode(@"\ue14c"), new GUIStyle { font = VectorImageManager.GetIconFont(VectorImageManager.materialDesignIconsFontName) }))
                {
                    IOptionDataListContainer optionDataListContainer = itemData.serializedObject.targetObject as IOptionDataListContainer;
                    VectorImageData data = optionDataListContainer.optionDataList.options[index].imageData.vectorImageData;
                    data.font = null;
                    data.glyph = null;
                    EditorUtility.SetDirty(itemData.serializedObject.targetObject);
                }
            }
        }
开发者ID:adamtelfer,项目名称:idlecraft,代码行数:68,代码来源:OptionDataListPropertyDrawer.cs

示例8: CreateDefaultOffset

		public static Rect CreateDefaultOffset(ref Rect rect) {
			var offset = new RectOffset(0, 0, -2, -2);
			return rect = offset.Add(rect);
		}
开发者ID:moto2002,项目名称:Inconspicuous.Framework,代码行数:4,代码来源:EditorUtility.cs


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