Exemple #1
0
    public override void OnGUI(Rect p_position, SerializedProperty p_property, GUIContent p_Label)
    {
        string _path    = p_property.propertyPath;
        bool   _isFirst = _path.EndsWith(".data[0]");

        if (_isFirst)
        {
            Rect _butRect = new Rect(p_position);
            int  _indent  = EditorGUI.indentLevel * 15;
            _butRect.height = 16;
            _butRect.x     += _indent;
            _butRect.width -= _indent + 160;
            GUI.Label(_butRect, "        CopyPaste-Array");

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

        CopyPasteAttribute _copyPaste = attribute as CopyPasteAttribute;

        Rect _copyPasteRect = new Rect(p_position);

        _copyPasteRect.x     += p_position.width - 120;
        _copyPasteRect.width  = 120;
        _copyPasteRect.height = 18;
        SerializedPropertyValue.DrawCopyPaste(_copyPasteRect, p_property);


        if ((p_property.propertyType == SerializedPropertyType.Generic) || (p_property.isArray && (p_property.propertyType != SerializedPropertyType.String)))
        {
            EditorGUI.PropertyField(p_position, p_property, true);
        }
        else
        {
            p_position.width -= 120;
            EditorGUI.PropertyField(p_position, p_property);
        }
    }
Exemple #2
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);
            }
        }
    }