@@ -103,12 +103,12 @@ void DrawMaterialsGUI()
103103 m_CustomPassMaterialsHash = materialsHash ;
104104 }
105105
106- Dictionary < SerializedProperty , CustomPassDrawer > customPassDrawers = new Dictionary < SerializedProperty , CustomPassDrawer > ( ) ;
107- CustomPassDrawer GetCustomPassDrawer ( SerializedProperty pass , int listIndex )
106+ Dictionary < CustomPass , CustomPassDrawer > customPassDrawers = new Dictionary < CustomPass , CustomPassDrawer > ( ) ;
107+ CustomPassDrawer GetCustomPassDrawer ( SerializedProperty pass , CustomPass reference , int listIndex )
108108 {
109109 CustomPassDrawer drawer ;
110110
111- if ( customPassDrawers . TryGetValue ( pass , out drawer ) )
111+ if ( customPassDrawers . TryGetValue ( reference , out drawer ) )
112112 return drawer ;
113113
114114 var customPass = m_Volume . customPasses [ listIndex ] ;
@@ -132,7 +132,7 @@ CustomPassDrawer GetCustomPassDrawer(SerializedProperty pass, int listIndex)
132132 }
133133 }
134134
135- customPassDrawers [ pass ] = drawer ;
135+ customPassDrawers [ reference ] = drawer ;
136136
137137 return drawer ;
138138 }
@@ -193,8 +193,9 @@ void CreateReorderableList(SerializedProperty passList)
193193 m_CustomPassList . drawElementCallback = ( rect , index , active , focused ) => {
194194 EditorGUI . BeginChangeCheck ( ) ;
195195
196+ passList . serializedObject . ApplyModifiedProperties ( ) ;
196197 var customPass = passList . GetArrayElementAtIndex ( index ) ;
197- var drawer = GetCustomPassDrawer ( customPass , index ) ;
198+ var drawer = GetCustomPassDrawer ( customPass , m_Volume . customPasses [ index ] , index ) ;
198199 if ( drawer != null )
199200 drawer . OnGUI ( rect , customPass , null ) ;
200201 else
@@ -205,8 +206,9 @@ void CreateReorderableList(SerializedProperty passList)
205206
206207 m_CustomPassList . elementHeightCallback = ( index ) =>
207208 {
209+ passList . serializedObject . ApplyModifiedProperties ( ) ;
208210 var customPass = passList . GetArrayElementAtIndex ( index ) ;
209- var drawer = GetCustomPassDrawer ( customPass , index ) ;
211+ var drawer = GetCustomPassDrawer ( customPass , m_Volume . customPasses [ index ] , index ) ;
210212 if ( drawer != null )
211213 return drawer . GetPropertyHeight ( customPass , null ) ;
212214 else
@@ -223,10 +225,10 @@ void CreateReorderableList(SerializedProperty passList)
223225 continue ;
224226
225227 menu . AddItem ( new GUIContent ( customPassType . Name ) , false , ( ) => {
226- passList . serializedObject . Update ( ) ;
228+ passList . serializedObject . ApplyModifiedProperties ( ) ;
227229 m_Volume . AddPassOfType ( customPassType ) ;
228230 UpdateMaterialEditors ( ) ;
229- passList . serializedObject . ApplyModifiedProperties ( ) ;
231+ passList . serializedObject . Update ( ) ;
230232 // Notify the prefab that something have changed:
231233 PrefabUtility . RecordPrefabInstancePropertyModifications ( target ) ;
232234 } ) ;
@@ -235,11 +237,25 @@ void CreateReorderableList(SerializedProperty passList)
235237 } ;
236238
237239 m_CustomPassList . onRemoveCallback = ( list ) => {
238- passList . serializedObject . Update ( ) ;
240+ passList . serializedObject . ApplyModifiedProperties ( ) ;
239241 Undo . RegisterCompleteObjectUndo ( target , "Remove custom pass" ) ;
240242 m_Volume . customPasses . RemoveAt ( list . index ) ;
241243 UpdateMaterialEditors ( ) ;
244+ passList . serializedObject . Update ( ) ;
245+ // Notify the prefab that something have changed:
246+ PrefabUtility . RecordPrefabInstancePropertyModifications ( target ) ;
247+ } ;
248+
249+ m_CustomPassList . onReorderCallbackWithDetails = ( list , oldIndex , newIndex ) => {
250+ customPassDrawers . Clear ( ) ;
242251 passList . serializedObject . ApplyModifiedProperties ( ) ;
252+ Undo . RegisterCompleteObjectUndo ( target , "Reorder custom pass" ) ;
253+
254+ var t = m_Volume . customPasses [ oldIndex ] ;
255+ m_Volume . customPasses [ oldIndex ] = m_Volume . customPasses [ newIndex ] ;
256+ m_Volume . customPasses [ newIndex ] = t ;
257+
258+ passList . serializedObject . Update ( ) ;
243259 // Notify the prefab that something have changed:
244260 PrefabUtility . RecordPrefabInstancePropertyModifications ( target ) ;
245261 } ;
0 commit comments