예제 #1
0
    public override float GetPropertyHeight(SerializedProperty p_property, GUIContent p_label)
    {
        string _path    = p_property.propertyPath;
        bool   _isFirst = _path.EndsWith(".data[0]");
        float  _height  = SerializedPropertyValue.GetPropertyHeight(p_property, p_label);

        if (_isFirst)
        {
            return(_height + 18);
        }
        else
        {
            return(_height);
        }
    }
예제 #2
0
    public static float GetPropertyHeight(SerializedProperty p_property, GUIContent p_label)
    {
        float _height = EditorGUIUtility.singleLineHeight;

        if (p_property.isExpanded)
        {
            IEnumerator        _enumerator = p_property.GetEnumerator();
            SerializedProperty _nowProperty;
            string             _hideProperty = "";

            while (_enumerator.MoveNext())
            {
                _nowProperty = (SerializedProperty)_enumerator.Current;

//				if((_nowProperty.propertyType == SerializedPropertyType.String) && (_nowProperty.stringValue == "@@@")){
//					Debug.Log("");
//				}

                string _nowPath = _nowProperty.propertyPath;

                if ((_hideProperty != "") && _nowPath.Contains(_hideProperty))
                {
                    continue;
                }
                else
                {
                    _hideProperty = "";
                }

                if (_nowProperty.isExpanded)
                {
                    _hideProperty = "";
                }
                else
                {
                    _hideProperty = _nowPath + ".";
                }

                _height += SerializedPropertyValue.GetPropertyHeight(_nowProperty, GUIContent.none) + 2;
            }
        }
        return(_height);
    }
예제 #3
0
    public override float GetPropertyHeight(SerializedProperty p_property, GUIContent p_label)
    {
        string _path   = p_property.propertyPath;
        float  _height = 0;
        ReorderableListAttribute _reorderableList = attribute as ReorderableListAttribute;
        bool _isFirst = _path.EndsWith(".data[0]");
        bool _isLast  = false;

        if (_reorderableList.list != null)
        {
            _isLast = _path.EndsWith(".data[" + (_reorderableList.list.count - 1) + "]");
        }
        if (useOrder && (_reorderableList.list != null))
        {
            if (_isFirst)
            {
                _height = _reorderableList.list.GetHeight() + 18;
            }
            else
            {
                _height = -2;
            }
        }
        else
        {
            _height = SerializedPropertyValue.GetPropertyHeight(p_property, p_label);
        }

        if ((_reorderableList.list != null) && !useOrder && _isLast)
        {
            return(_height + 18);
        }
        else
        {
            return(_height);
        }
    }
예제 #4
0
 public override float GetPropertyHeight(SerializedProperty p_property, GUIContent p_label)
 {
     return(SerializedPropertyValue.GetPropertyHeight(p_property, p_label));
 }
예제 #5
0
    public override void OnGUI(Rect p_position, SerializedProperty p_property, GUIContent p_label)
    {
        string _path = p_property.propertyPath;

        if (!_path.EndsWith("]"))
        {
            EditorGUI.LabelField(p_position, p_label.text, "[ReorderableList] Only for Array Or Collection");
            return;
        }

        ReorderableListAttribute _reorderableList = attribute as ReorderableListAttribute;
        bool _isFirst = _path.EndsWith(".data[0]");

        if (_reorderableList.list != null)
        {
            if (_isFirst)
            {
                Rect _butRect = new Rect(p_position);
                int  _indent  = EditorGUI.indentLevel * 15;
                _butRect.height = 16;
                if (useOrder)
                {
                    _butRect.x     += _indent + 70;
                    _butRect.width -= _indent + 70 + 160;
                    if (GUI.Button(_butRect, "Finish Reorder"))
                    {
                        useOrder = false;
                    }
                }
                else
                {
                    _butRect.x     += _indent;
                    _butRect.width -= _indent + 160;
                    if (GUI.Button(_butRect, "Start Reorder"))
                    {
                        useOrder = true;
                    }
                }

                _butRect.x    += _butRect.width;
                _butRect.width = 160;
                SerializedProperty _parentProperty = SerializedPropertyValue.GetParent(p_property);
                SerializedPropertyValue.DrawCopyPasteArray(_butRect, _parentProperty);
            }
        }

        SerializedObject _serializedObject = p_property.serializedObject;

        if (_isFirst)
        {
            if (_reorderableList.list == null)
            {
                SerializedProperty _parentProperty = SerializedPropertyValue.GetParent(p_property);
                _reorderableList.list = ReorderableListUtility.CreateAutoLayout(_parentProperty, 4, SerializedPropertyValue.DrawCopyPasteBehind);
            }
        }

        if (useOrder)
        {
            if (_isFirst)
            {
                p_position.width -= 120;
                ReorderableListUtility.DoListWithFoldout(_reorderableList.list, p_position);
            }
        }
        else
        {
            p_position.y += 16;

            Rect _copyPasteRect = new Rect(p_position);
            _copyPasteRect.x     += p_position.width - 120;
            _copyPasteRect.width  = 120;
            _copyPasteRect.height = 18;
            string _click = SerializedPropertyValue.DrawCopyPasteButton(_copyPasteRect, p_property);
            if (_click != "")
            {
            }
            else if ((p_property.propertyType == SerializedPropertyType.Generic) || (p_property.isArray && (p_property.propertyType != SerializedPropertyType.String)))
            {
                EditorGUI.PropertyField(p_position, p_property, p_label, true);
            }
            else
            {
                p_position.width -= 120;
                p_position.height = SerializedPropertyValue.GetPropertyHeight(p_property, p_label);
                EditorGUI.PropertyField(p_position, p_property);
            }
        }
    }