コード例 #1
0
    private void ListModified(ReorderableList list)
    {
        list.serializedProperty.serializedObject.ApplyModifiedProperties();

        switch (_currentListModification)
        {
        case LIST_MODIFICATION.ADD:
            _pathWayNavMeshUI.UpdatePathAt(_indexCurrentModification);
            break;

        case LIST_MODIFICATION.SUPP:
            if (list.serializedProperty.arraySize > 1)
            {
                _pathWayNavMeshUI.UpdatePathAt((list.serializedProperty.arraySize + _indexCurrentModification) % list.serializedProperty.arraySize);
            }
            break;

        case LIST_MODIFICATION.DRAG:
            _pathWayNavMeshUI.UpdatePathAt(list.index);
            _pathWayNavMeshUI.UpdatePathAt(_indexCurrentModification);
            break;

        default:
            break;
        }
        _currentListModification = LIST_MODIFICATION.OTHER;
    }
コード例 #2
0
    private void RemoveItem(ReorderableList list)
    {
        int index = list.index;

        list.serializedProperty.DeleteArrayElementAtIndex(index);

        if (list.index == list.serializedProperty.arraySize)
        {
            list.index--;
        }
        _indexCurrentModification = index - 1;
        _currentListModification  = LIST_MODIFICATION.SUPP;
    }
コード例 #3
0
 private void OnEnable()
 {
     Undo.undoRedoPerformed += DoUndo;
     _reorderableList        = new ReorderableList(serializedObject, serializedObject.FindProperty("Waypoints"), true, true, true, true);
     _reorderableList.drawHeaderCallback  += DrawHeader;
     _reorderableList.drawElementCallback += DrawElement;
     _reorderableList.onAddCallback       += AddItem;
     _reorderableList.onRemoveCallback    += RemoveItem;
     _reorderableList.onChangedCallback   += ListModified;
     _reorderableList.onMouseDragCallback += DragItem;
     _pathway                 = (target as Pathway);
     _pathWayNavMeshUI        = new PathWayNavMeshUI(_pathway);
     _pathwayHandles          = new PathwayHandles(_pathway);
     _currentListModification = LIST_MODIFICATION.OTHER;
 }
コード例 #4
0
    private void AddItem(ReorderableList list)
    {
        int index = list.index;

        if (index > -1 && list.serializedProperty.arraySize >= 1)
        {
            list.serializedProperty.InsertArrayElementAtIndex(index + 1);
            Vector3 previous = list.serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("waypoint").vector3Value;
            list.serializedProperty.GetArrayElementAtIndex(index + 1).FindPropertyRelative("waypoint").vector3Value = new Vector3(previous.x + 2, previous.y, previous.z + 2);
            _indexCurrentModification = index + 1;
        }
        else
        {
            list.serializedProperty.InsertArrayElementAtIndex(list.serializedProperty.arraySize);
            Vector3 previous = Vector3.zero;
            list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).FindPropertyRelative("waypoint").vector3Value = new Vector3(previous.x + 2, previous.y, previous.z + 2);
            _indexCurrentModification = list.serializedProperty.arraySize - 1;
        }
        _currentListModification = LIST_MODIFICATION.ADD;
        list.index++;
    }
コード例 #5
0
 private void DragItem(ReorderableList list)
 {
     _indexCurrentModification = list.index;
     _currentListModification  = LIST_MODIFICATION.DRAG;
 }