@@ -17,12 +17,12 @@ public class DllManipulatorEditor : Editor
1717 private static readonly GUIContent TARGET_ALL_NATIVE_FUNCTIONS_GUI_CONTENT = new GUIContent ( "All native functions" ,
1818 "If true, all found native functions will be mocked.\n \n " +
1919 $ "If false, you have to select them by using [{ nameof ( MockNativeDeclarationsAttribute ) } ] or [{ nameof ( MockNativeDeclarationAttribute ) } ].") ;
20- private static readonly GUIContent TARGET_ONLY_EXECUTING_ASSEMBLY_GUI_CONTENT = new GUIContent ( "Only executing assembly " ,
21- "If true, native functions will be mocked only in assembly that contains DllManipulator (usually Assembly-CSharp) " ) ;
20+ private static readonly GUIContent ONLY_ASSEMBLY_CSHARP_GUI_CONTENT = new GUIContent ( "Only Assembly-CSharp(-Editor) " ,
21+ "If true, native functions will be mocked only in Assembly-CSharp and Assembly-CSharp-Editor. Alternatively enter a list of assembly names. " ) ;
2222 private static readonly GUIContent ONLY_IN_EDITOR = new GUIContent ( "Only in editor" ,
2323 "Whether to run only inside editor (which is recommended)." ) ;
2424 private static readonly GUIContent TARGET_ASSEMBLIES_GUI_CONTENT = new GUIContent ( "Target assemblies" ,
25- "Choose from which assemblies to mock native functions" ) ;
25+ "List of assembly names to mock native functions in (no file extension). " ) ;
2626 private static readonly GUIContent DLL_PATH_PATTERN_GUI_CONTENT = new GUIContent ( "DLL path pattern" ,
2727 "Available macros:\n \n " +
2828 $ "{ DllManipulator . DLL_PATH_PATTERN_DLL_NAME_MACRO } - name of DLL as specified in [DllImport] attribute.\n \n " +
@@ -53,7 +53,6 @@ public class DllManipulatorEditor : Editor
5353 "Use only if you are sure no other thread will be call mocked natives." ) ;
5454 private static readonly GUIContent UNLOAD_ALL_DLLS_AND_PAUSE_WITH_THREAD_SAFETY_GUI_CONTENT = new GUIContent ( "Unload all DLLs & Pause [dangerous]" ,
5555 "Use only if you are sure no other thread will be call mocked natives." ) ;
56- private static readonly TimeSpan ASSEMBLIES_REFRESH_INTERVAL = TimeSpan . FromSeconds ( 1 ) ;
5756
5857 private bool _showLoadedLibraries = true ;
5958 private bool _showTargetAssemblies = true ;
@@ -181,63 +180,25 @@ private void DrawOptions(DllManipulatorOptions options)
181180 GUI . enabled = false ;
182181 options . mockAllNativeFunctions = EditorGUILayout . Toggle ( TARGET_ALL_NATIVE_FUNCTIONS_GUI_CONTENT , options . mockAllNativeFunctions ) ;
183182
184- if ( EditorGUILayout . Toggle ( TARGET_ONLY_EXECUTING_ASSEMBLY_GUI_CONTENT , options . assemblyPaths . Length == 0 ) )
183+ if ( EditorGUILayout . Toggle ( ONLY_ASSEMBLY_CSHARP_GUI_CONTENT , options . assemblyNames . Count == 0 ) )
185184 {
186- options . assemblyPaths = new string [ 0 ] ;
185+ options . assemblyNames . Clear ( ) ;
187186 }
188187 else
189188 {
190189 var prevIndent1 = EditorGUI . indentLevel ;
191190 EditorGUI . indentLevel ++ ;
192191
193- if ( _allKnownAssemblies == null || _lastKnownAssembliesRefreshTime + ASSEMBLIES_REFRESH_INTERVAL < DateTime . Now )
194- {
195- var playerCompiledAssemblies = CompilationPipeline . GetAssemblies ( AssembliesType . Player )
196- . Select ( a => PathUtils . NormallizeUnityAssemblyPath ( a . outputPath ) ) ;
197-
198- var editorCompiledAssemblies = CompilationPipeline . GetAssemblies ( AssembliesType . Editor )
199- . Select ( a => PathUtils . NormallizeUnityAssemblyPath ( a . outputPath ) ) ;
200-
201- var assemblyAssets = Resources . FindObjectsOfTypeAll < PluginImporter > ( )
202- . Where ( p => ! p . isNativePlugin )
203- . Select ( p => PathUtils . NormallizeUnityAssemblyPath ( p . assetPath ) ) ;
204-
205- string [ ] defaultAssemblyPrefixes = { "UnityEngine." , "UnityEditor." , "Unity." , "com.unity." , "Mono." , "nunit." } ;
206-
207- _allKnownAssemblies = playerCompiledAssemblies
208- . Concat ( assemblyAssets )
209- . Concat ( editorCompiledAssemblies )
210- . OrderBy ( path => Array . FindIndex ( defaultAssemblyPrefixes , p => path . Substring ( path . LastIndexOf ( '/' ) + 1 ) . StartsWith ( p ) ) )
211- . ToArray ( ) ;
212- _lastKnownAssembliesRefreshTime = DateTime . Now ;
213- }
214-
215- if ( options . assemblyPaths . Length == 0 )
216- {
217- var first = GetFirstAssemblyToList ( _allKnownAssemblies ) ;
218- if ( first != null )
219- options . assemblyPaths = new [ ] { first } ;
220- }
192+ if ( options . assemblyNames . Count == 0 )
193+ options . assemblyNames . AddRange ( DllManipulator . DEFAULT_ASSEMBLY_NAMES ) ;
221194
222195 _showTargetAssemblies = EditorGUILayout . Foldout ( _showTargetAssemblies , TARGET_ASSEMBLIES_GUI_CONTENT ) ;
223196 if ( _showTargetAssemblies )
224197 {
225198 var prevIndent2 = EditorGUI . indentLevel ;
226199 EditorGUI . indentLevel ++ ;
227200
228- var selectedAssemblies = options . assemblyPaths . Where ( p => _allKnownAssemblies . Any ( a => PathUtils . DllPathsEqual ( a , p ) ) ) . ToList ( ) ;
229- var notSelectedAssemblies = _allKnownAssemblies . Except ( selectedAssemblies ) . ToArray ( ) ;
230- DrawList ( selectedAssemblies , i =>
231- {
232- var values = new [ ] { selectedAssemblies [ i ] }
233- . Concat ( notSelectedAssemblies )
234- . Select ( a => a . Substring ( a . LastIndexOf ( '/' ) + 1 ) )
235- . ToArray ( ) ;
236-
237- var selectedIndex = EditorGUILayout . Popup ( 0 , values ) ;
238- return selectedIndex == 0 ? selectedAssemblies [ i ] : notSelectedAssemblies [ selectedIndex - 1 ] ;
239- } , notSelectedAssemblies . Length > 0 , ( ) => notSelectedAssemblies [ 0 ] ) ;
240- options . assemblyPaths = selectedAssemblies . ToArray ( ) ;
201+ DrawList ( options . assemblyNames , i => EditorGUILayout . TextField ( options . assemblyNames [ i ] ) , true , ( ) => "" ) ;
241202
242203 EditorGUI . indentLevel = prevIndent2 ;
243204 }
0 commit comments