コード例 #1
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <Vector2Int> entry, GUIContent label)
        {
            GUILayout.BeginHorizontal();

            if (label != null)
            {
                EditorGUI.BeginChangeCheck();
                var value = SirenixEditorFields.VectorPrefixLabel(label, (Vector2)entry.SmartValue);
                if (EditorGUI.EndChangeCheck())
                {
                    entry.SmartValue = new Vector2Int((int)value.x, (int)value.y);
                }
            }

            var  r          = GUIHelper.GetCurrentLayoutRect();
            bool showLabels = !(SirenixEditorFields.ResponsiveVectorComponentFields && (label != null ? r.width - EditorGUIUtility.labelWidth : r.width) < 185);

            GUIHelper.PushLabelWidth(SirenixEditorFields.SingleLetterStructLabelWidth);
            GUIHelper.PushIndentLevel(0);
            entry.Property.Children[0].Draw(showLabels ? GUIHelper.TempContent("X") : null);
            entry.Property.Children[1].Draw(showLabels ? GUIHelper.TempContent("Y") : null);
            GUIHelper.PopIndentLevel();
            GUIHelper.PopLabelWidth();
            GUILayout.EndHorizontal();
        }
コード例 #2
0
        private void DrawValues(IPropertyValueEntry <Rect> entry)
        {
            var value = entry.SmartValue;

            // Position
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUI.BeginChangeCheck();
                value.position = SirenixEditorFields.VectorPrefixLabel("Position", value.position);
                if (EditorGUI.EndChangeCheck())
                {
                    entry.SmartValue = value;
                }

                GUIHelper.PushIndentLevel(0);
                GUIHelper.PushLabelWidth(SirenixEditorFields.SingleLetterStructLabelWidth);
                entry.Property.Children[0].Draw(GUIHelper.TempContent("X"));
                entry.Property.Children[1].Draw(GUIHelper.TempContent("Y"));
                GUIHelper.PopLabelWidth();
                GUIHelper.PopIndentLevel();
            }
            EditorGUILayout.EndHorizontal();

            // Size
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUI.BeginChangeCheck();
                value.size = SirenixEditorFields.VectorPrefixLabel("Size", value.size);
                if (EditorGUI.EndChangeCheck())
                {
                    entry.SmartValue = value;
                }

                GUIHelper.PushIndentLevel(0);
                GUIHelper.PushLabelWidth(SirenixEditorFields.SingleLetterStructLabelWidth);
                entry.Property.Children[2].Draw(GUIHelper.TempContent("X"));
                entry.Property.Children[3].Draw(GUIHelper.TempContent("Y"));
                GUIHelper.PopLabelWidth();
                GUIHelper.PopIndentLevel();
            }
            EditorGUILayout.EndHorizontal();
        }
コード例 #3
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <Vector3> entry, GUIContent label)
        {
            if (label == null)
            {
                AllEditorGUI.BeginIndentedHorizontal(EditorGUI.indentLevel == 0 ? GUIStyle.none : SirenixGUIStyles.PropertyMargin);
            }
            else
            {
                GUILayout.BeginHorizontal();
            }

            if (label != null)
            {
                EditorGUI.BeginChangeCheck();
                var value = SirenixEditorFields.VectorPrefixLabel(label, entry.SmartValue);
                if (EditorGUI.EndChangeCheck())
                {
                    entry.SmartValue = value;
                }
            }

            var  r          = GUIHelper.GetCurrentLayoutRect();
            bool showLabels = !(SirenixEditorFields.ResponsiveVectorComponentFields && (label != null ? r.width - EditorGUIUtility.labelWidth : r.width) < 185);

            GUIHelper.PushLabelWidth(SirenixEditorFields.SingleLetterStructLabelWidth);
            GUIHelper.PushIndentLevel(0);
            entry.Property.Children[0].Draw(showLabels ? GUIHelper.TempContent("X") : null);
            entry.Property.Children[1].Draw(showLabels ? GUIHelper.TempContent("Y") : null);
            entry.Property.Children[2].Draw(showLabels ? GUIHelper.TempContent("Z") : null);
            GUIHelper.PopIndentLevel();
            GUIHelper.PopLabelWidth();

            if (label == null)
            {
                AllEditorGUI.EndIndentedHorizontal();
            }
            else
            {
                GUILayout.EndHorizontal();
            }
        }