Beispiel #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            property.isExpanded = EditorGUI.Foldout(new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight),
                                                    property.isExpanded, property.displayName, true);

            if (property.isExpanded)
            {
                if (null == targetArray)
                {
                    targetArray = GetTargetArray(property);
                }
                position.x     += indent;
                position.width -= indent;
                ShowGUI(position, property);
            }

            EditorGUI.EndProperty();
        }
Beispiel #2
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float sumHeight = 0;

            sumHeight += labelHeight + EditorGUIUtility.standardVerticalSpacing;

            if (!property.isExpanded)
            {
                return(sumHeight);
            }

            if (null == targetArray)
            {
                targetArray = GetTargetArray(property);
            }

            if (targetArray == null)
            {
                Debug.LogError(property.name + " object is null.");
                GUIUtility.ExitGUI();
                return(sumHeight);
            }

            if (targetArray.Length <= 0)
            {
                sumHeight += helpBoxHeight + EditorGUIUtility.standardVerticalSpacing;
            }
            for (int i = 0; i < targetArray.Length; ++i)
            {
                sumHeight += elementHeight + EditorGUIUtility.standardVerticalSpacing;
            }
            if (targetArray.Length < targetArray.MaxLength)
            {
                sumHeight += longButtonHeight + EditorGUIUtility.standardVerticalSpacing;
            }
            return(sumHeight);
        }