Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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

Discussion in 'Editor & General Support' started by lTimesl, Dec 29, 2020.

  1. lTimesl

    lTimesl

    Joined:
    Feb 7, 2019
    Posts:
    8
    hey there

    i mead Quest tool which is node window editor every node represent Quest the Quest class hold list of Tasks i serialized this list to a Reorderable List

    my problem is i don't know how to reset the event value when new element added to the Reorderable List i mead search via google i learned how to override the Reorderable List Callbacks so i did override onAddcallback this work fine except i dont find any event value to reset it i found int string object etc..

    so to make my problem clear i upload image to show the problem clearly as you can see in the image the event value was passed in the new element

    rrrr.png
    if anyone here know it plls help me to solve it thanks in advance unity community

    this onaddcallback func

    Code (CSharp):
    1.              onAddCallback = list =>
    2.              {
    3.                  var index = list.serializedProperty.arraySize;
    4.                  list.serializedProperty.arraySize++;
    5.                  list.index = index;
    6.                  var element = list.serializedProperty.GetArrayElementAtIndex(index);
    7.                  //properties of the element in SerializedProperties
    8.                  var task = element.FindPropertyRelative("task");
    9.                  var searchType = element.FindPropertyRelative("searchType");
    10.                  var target = element.FindPropertyRelative("target");
    11.                  var deliverdTaregt = element.FindPropertyRelative("deliverdTaregt");
    12.                  var isCountNeeded = element.FindPropertyRelative("isCountNeeded");
    13.                  var targetLocation = element.FindPropertyRelative("targetLocation");
    14.                  var taskHint = element.FindPropertyRelative("taskHint");
    15.                  var OnTaskStart = element.FindPropertyRelative("OnTaskStart");
    16.                  var OnTaskEnd = element.FindPropertyRelative("OnTaskEnd");
    17.                  var boxColliderSize = element.FindPropertyRelative("colliderSize");
    18.                  var requairdCount = element.FindPropertyRelative("requairdCount");
    19.                  // default values
    20.                  task.intValue = (int)Tasks.TaskType.Search;
    21.                  searchType.intValue = (int)Tasks.SearchType.gameObject;
    22.                  target.objectReferenceValue = null;
    23.                  deliverdTaregt.objectReferenceValue = null;
    24.                  isCountNeeded.boolValue = false;
    25.                  targetLocation.vector3Value = Vector3.zero;
    26.                  boxColliderSize.vector3Value = Vector3.zero;
    27.                  taskHint.stringValue = "";
    28.                  requairdCount.intValue = 0;
    29.                
    30.              }
    the task class i create the list of it

    Code (CSharp):
    1.  using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEditor;
    4. using UnityEngine;
    5. using UnityEngine.Events;
    6. [System.Serializable]
    7. public class Tasks
    8. {
    9.      public enum TaskType { Search, Deliver, Counter, Hunt }
    10.      public enum SearchType { gameObject, Area }
    11.      public GameObject target, deliverdTaregt;
    12.      [TextArea]
    13.      public string taskHint;
    14.      public bool isCountNeeded;
    15.      public int requairdCount;
    16.      public Vector3 targetLocation, colliderSize;
    17.      public TaskType task;
    18.      public SearchType searchType;
    19.      public bool isFoldout;
    20.      public UnityEvent OnTaskStart;
    21.      public UnityEvent OnTaskEnd;
    22. }
     
  2. lTimesl

    lTimesl

    Joined:
    Feb 7, 2019
    Posts:
    8