Undo.RecordObject를 쓰면 자동으로 target을 SetDirty 해준다길래
SerializedProperty를 통하지 않고 변수에 접근하고 있었다. 근데 제대로 작동 안 할 때가 있잖아? Prefab Instance에 있는 list를 수정할 때가 그랬다. (unity 2018.3.0f2)
They told me that Undo.
강제로 뒤에 EditorUtility.SetDirty를 호출하면 해결되지만 영 찜찜하다.
결국 Unity에서 하라는대로 SerializedProperty를 통해 변수를 수정했다.
1 2 3 4 5 6 |
SerializedProperty listProperty = serializedObject.FindProperty("list"); // ... reorderable.onRemoveCallback = list => { listProperty.DeleteArrayElementAtIndex(list.index); }; |