@@ -101,7 +101,15 @@ public void AddProperty(SerializedProperty property)
101101
102102 propList . drawElementCallback = delegate ( Rect rect , int index , bool active , bool focused )
103103 {
104- SerializedProperty targetElement = property . GetArrayElementAtIndex ( index ) ;
104+ SerializedProperty targetElement ;
105+ try
106+ {
107+ targetElement = property . GetArrayElementAtIndex ( index ) ;
108+ }
109+ catch ( NullReferenceException )
110+ {
111+ return ;
112+ }
105113
106114 bool isExpanded = targetElement . isExpanded ;
107115 rect . height = EditorGUI . GetPropertyHeight ( targetElement , GUIContent . none , isExpanded ) ;
@@ -148,7 +156,15 @@ public void AddProperty(SerializedProperty property)
148156
149157 private float ElementHeightCallback ( SerializedProperty property , int index )
150158 {
151- SerializedProperty arrayElement = property . GetArrayElementAtIndex ( index ) ;
159+ SerializedProperty arrayElement ;
160+ try
161+ {
162+ arrayElement = property . GetArrayElementAtIndex ( index ) ;
163+ }
164+ catch ( NullReferenceException )
165+ {
166+ return 0f ;
167+ }
152168 float calculatedHeight = EditorGUI . GetPropertyHeight ( arrayElement ,
153169 GUIContent . none ,
154170 arrayElement . isExpanded ) ;
@@ -319,7 +335,9 @@ protected virtual void InitInspector()
319335 if ( isInitialized && FORCE_INIT == false )
320336 return ;
321337
322- styleEditBox = new GUIStyle ( EditorStyles . helpBox ) { padding = new RectOffset ( 5 , 5 , 5 , 5 ) } ;
338+ try { styleEditBox = new GUIStyle ( EditorStyles . helpBox ) { padding = new RectOffset ( 5 , 5 , 5 , 5 ) } ; }
339+ catch ( NullReferenceException ) { return ; }
340+
323341 FindTargetProperties ( ) ;
324342 FindContextMenu ( ) ;
325343 }
@@ -612,7 +630,11 @@ public override void OnInspectorGUI()
612630
613631 if ( EditorGUI . EndChangeCheck ( ) )
614632 {
615- serializedObject . ApplyModifiedProperties ( ) ;
633+ try
634+ {
635+ serializedObject . ApplyModifiedProperties ( ) ;
636+ }
637+ catch ( System . Exception ) { return ; }
616638 InitInspector ( true ) ;
617639 }
618640
@@ -630,27 +652,34 @@ protected void IterateDrawProperty(SerializedProperty property, Func<IterControl
630652 {
631653 if ( property . NextVisible ( true ) )
632654 {
633- // Remember depth iteration started from
634- int depth = property . Copy ( ) . depth ;
635- do
655+ try
636656 {
637- // If goes deeper than the iteration depth, get out
638- if ( property . depth != depth )
639- break ;
640- if ( isSubEditor && property . name . Equals ( "m_Script" ) )
641- continue ;
642-
643- if ( filter != null )
657+ // Remember depth iteration started from
658+ int depth = property . Copy ( ) . depth ;
659+ do
644660 {
645- var filterResult = filter ( ) ;
646- if ( filterResult == IterControl . Break )
661+ // If goes deeper than the iteration depth, get out
662+ if ( property . depth != depth )
647663 break ;
648- if ( filterResult == IterControl . Continue )
664+ if ( isSubEditor && property . name . Equals ( "m_Script" ) )
649665 continue ;
650- }
651666
652- DrawPropertySortableArray ( property ) ;
653- } while ( property . NextVisible ( false ) ) ;
667+ if ( filter != null )
668+ {
669+ var filterResult = filter ( ) ;
670+ if ( filterResult == IterControl . Break )
671+ break ;
672+ if ( filterResult == IterControl . Continue )
673+ continue ;
674+ }
675+
676+ DrawPropertySortableArray ( property ) ;
677+ } while ( property == null || property . NextVisible ( false ) ) ;
678+ }
679+ catch ( NullReferenceException )
680+ {
681+ return ;
682+ }
654683 }
655684 }
656685
0 commit comments