private float ElementHeightCallback(int idx) { //return listExample._cdtList[idx].ItemSize; return(ConditionDrawingHelper.GetItemSize(listExample._cdtList[idx])); }
private void DrawElement(Rect rect, int index, bool active, bool focused) { var item = listExample._cdtList[index]; Rect newRect = rect; //var s = serializedObject; //s.Update(); EditorGUI.BeginChangeCheck(); newRect.y += 20; newRect.x += 18; //item.Test = EditorGUI.TextField(new Rect(rect.x + 18, rect.y, rect.width - 18, rect.height), ConditionItem.Outputs[0].Item1); // Draws the condition item selector item.SelectedIndex = EditorGUI.Popup(new Rect(rect.x + 18, rect.y + 2, rect.width - 18, 20), item.SelectedIndex, item.Outputs); //Debug.Log("Before drawing y=" + newRect.y); //newRect.y += item.Draw(newRect); newRect.y += ConditionDrawingHelper.Draw(item, newRect); //Debug.Log("After drawing y=" + newRect.y); // Draws the callback zone to assign it //SerializedObject s = new SerializedObject(listExample); var p = serializedObject.FindProperty("_cdtList").GetArrayElementAtIndex(index); //EditorGUI.PropertyField(new Rect(rect.x + 18, newRect.y + 5, rect.width - 18, 20), p.FindPropertyRelative("OnOutputChanged")); //var p = serializedObject.FindProperty("OnOutputChanged"); //EditorGUIUtility.LookLikeControls(); //Debug.Log("p is => " + p); var it = p.serializedObject.GetIterator(); p.Next(true); p.Next(false); p.Next(false); p.Next(false); p.Next(false); EditorGUI.PropertyField(new Rect(rect.x + 18, newRect.y + 5, rect.width - 18, 20), p); item.CallbackCount = item.OnOutputChanged.GetPersistentEventCount(); //foreach (var x in p) //{ // var u = x as SerializedProperty; // if (u.name == "size") // { // Debug.Log("found size " + u.intValue); // item.CallbackCount = u.intValue; // Repaint(); // break; // } //} if (EditorGUI.EndChangeCheck()) { //Debug.Log("end change check true"); EditorUtility.SetDirty(target); //Debug.Log("End change check !"); Repaint(); } //s.ApplyModifiedPropertiesWithoutUndo(); }