@@ -20,7 +20,6 @@ public class CollectionSettings
20
20
public bool WriteAddressableLoadingMethods ;
21
21
22
22
private AssetImporter importer ;
23
- private bool isDirty ;
24
23
25
24
public CollectionSettings ( )
26
25
{
@@ -56,7 +55,7 @@ public CollectionSettings(ScriptableObjectCollection targetCollection)
56
55
WriteAsPartialClass = canBePartial ;
57
56
UseBaseClassForItems = false ;
58
57
EnforceIndirectAccess = false ;
59
- isDirty = true ;
58
+ Save ( ) ;
60
59
}
61
60
62
61
public bool ShouldWriteAddressableLoadingMethods ( )
@@ -67,31 +66,27 @@ public bool ShouldWriteAddressableLoadingMethods()
67
66
return WriteAddressableLoadingMethods ;
68
67
}
69
68
70
- public void SetWriteAddressableLoadingMethods ( bool shouldWriteAddressablesMethods )
71
- {
72
- if ( WriteAddressableLoadingMethods == shouldWriteAddressablesMethods )
73
- return ;
74
-
75
- WriteAddressableLoadingMethods = shouldWriteAddressablesMethods ;
76
- isDirty = true ;
77
- }
78
-
79
69
public void SetImporter ( AssetImporter targetImporter )
80
70
{
81
71
importer = targetImporter ;
82
72
}
83
73
84
74
public void Save ( )
85
75
{
86
- if ( ! isDirty )
87
- return ;
88
-
89
76
if ( importer == null )
90
77
return ;
91
78
92
79
importer . userData = EditorJsonUtility . ToJson ( this ) ;
93
- importer . SaveAndReimport ( ) ;
94
- isDirty = false ;
80
+ AssetDatabase . WriteImportSettingsIfDirty ( importer . assetPath ) ;
81
+ }
82
+
83
+ public void SetWriteAddressableLoadingMethods ( bool shouldWriteAddressablesMethods )
84
+ {
85
+ if ( WriteAddressableLoadingMethods == shouldWriteAddressablesMethods )
86
+ return ;
87
+
88
+ WriteAddressableLoadingMethods = shouldWriteAddressablesMethods ;
89
+ Save ( ) ;
95
90
}
96
91
97
92
public void SetEnforceIndirectAccess ( bool enforceIndirectAccess )
@@ -100,7 +95,7 @@ public void SetEnforceIndirectAccess(bool enforceIndirectAccess)
100
95
return ;
101
96
102
97
EnforceIndirectAccess = enforceIndirectAccess ;
103
- isDirty = true ;
98
+ Save ( ) ;
104
99
}
105
100
106
101
public void SetStaticFilename ( string targetNewName )
@@ -109,7 +104,7 @@ public void SetStaticFilename(string targetNewName)
109
104
return ;
110
105
111
106
StaticFilename = targetNewName ;
112
- isDirty = true ;
107
+ Save ( ) ;
113
108
}
114
109
115
110
public void SetNamespace ( string targetNamespace )
@@ -118,7 +113,7 @@ public void SetNamespace(string targetNamespace)
118
113
return ;
119
114
120
115
Namespace = targetNamespace ;
121
- isDirty = true ;
116
+ Save ( ) ;
122
117
}
123
118
124
119
public void SetWriteAsPartialClass ( bool writeAsPartial )
@@ -127,7 +122,7 @@ public void SetWriteAsPartialClass(bool writeAsPartial)
127
122
return ;
128
123
129
124
WriteAsPartialClass = writeAsPartial ;
130
- isDirty = true ;
125
+ Save ( ) ;
131
126
}
132
127
133
128
public void SetUseBaseClassForItems ( bool useBaseClass )
@@ -136,7 +131,7 @@ public void SetUseBaseClassForItems(bool useBaseClass)
136
131
return ;
137
132
138
133
UseBaseClassForItems = useBaseClass ;
139
- isDirty = true ;
134
+ Save ( ) ;
140
135
}
141
136
142
137
public void SetParentFolderPath ( string assetPath )
@@ -145,7 +140,7 @@ public void SetParentFolderPath(string assetPath)
145
140
return ;
146
141
147
142
ParentFolderPath = assetPath ;
148
- isDirty = true ;
143
+ Save ( ) ;
149
144
}
150
145
}
151
146
}
0 commit comments