how to stop reorderable list from passing Event value to the new element

Hey there,

I made a Quest tool which is a node window editor. Every node represents a Quest. The Quest class holds a list of Tasks which I serialised from a ReorderableList

My problem is that I don’t know how to reset the event value when new element added to the Reorderable List.

I searched (via google) and I learned how to override the ReorderableList Callbacks. When I overrided the
onAdd callback it worked fine, however now I don’t find any event to reset the value. I found int string object etc…


To make my problem clearer I have uploaded the image below. As you can see in the image the event value was passed into the new element


Thanks in advance unity community to anyone here that knows how and can help me.

this is the onAddCallback function

 onAddCallback = list =>
                {
    
                    var index = list.serializedProperty.arraySize;
    
    
                    list.serializedProperty.arraySize++;
                    list.index = index;
    
                    var element = list.serializedProperty.GetArrayElementAtIndex(index);
    
                    //properties of the element in SerializedProperties
                    var task = element.FindPropertyRelative("task");
                    var searchType = element.FindPropertyRelative("searchType");
                    var target = element.FindPropertyRelative("target");
                    var deliverdTaregt = element.FindPropertyRelative("deliverdTaregt");
                    var isCountNeeded = element.FindPropertyRelative("isCountNeeded");
                    var targetLocation = element.FindPropertyRelative("targetLocation");
                    var taskHint = element.FindPropertyRelative("taskHint");
                    var OnTaskStart = element.FindPropertyRelative("OnTaskStart");
                    var OnTaskEnd = element.FindPropertyRelative("OnTaskEnd");
                    var boxColliderSize = element.FindPropertyRelative("colliderSize");
                    var requairdCount = element.FindPropertyRelative("requairdCount");
    
                    // default values
                    task.intValue = (int)Tasks.TaskType.Search;
                    searchType.intValue = (int)Tasks.SearchType.gameObject;
                    target.objectReferenceValue = null;
                    deliverdTaregt.objectReferenceValue = null;
                    isCountNeeded.boolValue = false;
                    targetLocation.vector3Value = Vector3.zero;
                    boxColliderSize.vector3Value = Vector3.zero;
                    taskHint.stringValue = "";
                    requairdCount.intValue = 0;
                    
    
                }

the task class i create the list of it


using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;

[System.Serializable]
public class Tasks
{
    public enum TaskType { Search, Deliver, Counter, Hunt }
    public enum SearchType { gameObject, Area }
    public GameObject target, deliverdTaregt;
    [TextArea]
    public string taskHint;
    public bool isCountNeeded;

    public int requairdCount;

    public Vector3 targetLocation, colliderSize;

    public TaskType task;
    public SearchType searchType;
    public bool isFoldout;
    public UnityEvent OnTaskStart;
    public UnityEvent OnTaskEnd;
}

In case anyone comes by this thread, because the drawers are instanced grouped into a single instance, so you need to reference the proper serializedproperty. I the example case, you simply keep a reference to the property’s path as the key in a dictionary.