コード例 #1
0
            public override float GetPropertyHeight(UnityEditor.SerializedProperty property, GUIContent label)
            {
                InlineAttribute attr = (InlineAttribute)attribute;

                float height = CalculateHeight(property);

                if (!property.hasVisibleChildren || attr.m_DisplayType == DisplayType.RegularLabel)
                {
                    return(height);
                }

                if (attr.m_DisplayType == DisplayType.HeaderLabel)
                {
                    return(height + 8);
                }

                return(height - UnityEditor.EditorGUIUtility.singleLineHeight - 2);
            }
コード例 #2
0
            public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
            {
                label = UnityEditor.EditorGUI.BeginProperty(position, label, property);

                if (!property.hasVisibleChildren)
                {
                    UnityEditor.EditorGUI.PropertyField(position, property, label);
                }
                else
                {
                    InlineAttribute attr        = (InlineAttribute)attribute;
                    Rect            currentRect = UnityEditor.EditorGUI.IndentedRect(position);
                    currentRect.height = UnityEditor.EditorGUIUtility.singleLineHeight;
                    if (attr.m_DisplayType == DisplayType.RegularLabel)
                    {
                        UnityEditor.EditorGUI.LabelField(currentRect, label);
                        currentRect.y += currentRect.height + 2;
                    }
                    else if (attr.m_DisplayType == DisplayType.HeaderLabel)
                    {
                        currentRect.y += 8;
                        UnityEditor.EditorGUI.LabelField(currentRect, label, UnityEditor.EditorStyles.boldLabel);
                        currentRect.y += currentRect.height + 2;
                    }

                    UnityEditor.SerializedProperty endProperty = property.GetEndProperty();
                    bool bEnterChildren = true;
                    while (property.NextVisible(bEnterChildren) && !UnityEditor.SerializedProperty.EqualContents(property, endProperty))
                    {
                        currentRect.height = UnityEditor.EditorGUI.GetPropertyHeight(property, true);
                        UnityEditor.EditorGUI.PropertyField(currentRect, property, true);
                        currentRect.y += currentRect.height + 2;
                        bEnterChildren = false;
                    }
                }

                UnityEditor.EditorGUI.EndProperty();
            }