CurrentDomain
How do I use Current Domain
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PhotonEditor.cs
Copy
975 public static System.Type[] GetAllSubTypesInScripts(System.Type aBaseClass)
976 {
977 var result = new System.Collections.Generic.List
978 System.Reflection.Assembly[] AS = System.AppDomain.CurrentDomain.GetAssemblies();
979 foreach (var A in AS)
980 {
981 // this skips all but the Unity-scripted assemblies for RPC-list creation. You could remove this to search all assemblies in project
982 if (!A.FullName.StartsWith("Assembly-"))
983 {
984 // Debug.Log("Skipping Assembly: " + A);
985 continue;
986 }
987
988 //Debug.Log("Assembly: " + A.FullName);
989 System.Type[] types = A.GetTypes();
990 foreach (var T in types)
991 {
992 if (T.IsSubclassOf(aBaseClass))
993 result.Add(T);
994 }
995 }
996 return result.ToArray();
997 }
File name: VSCode.cs
Copy
304 static VSCode()
305 {
306 if (Enabled)
307 {
308 UpdateUnityPreferences(true);
309 UpdateLaunchFile();
310
311 // Add Update Check
312 DateTime targetDate = LastUpdate.AddDays(UpdateTime);
313 if (DateTime.Now >= targetDate && AutomaticUpdates)
314 {
315 CheckForUpdate();
316 }
317
318 // Open VS Code automatically when project is loaded
319 if (AutoOpenEnabled)
320 {
321 CheckForAutoOpen();
322 }
323
324 }
325
326 // Event for when script is reloaded
327 System.AppDomain.CurrentDomain.DomainUnload += System_AppDomain_CurrentDomain_DomainUnload;
328 }
File name: VSCode.cs
Copy
329 static void System_AppDomain_CurrentDomain_DomainUnload(object sender, System.EventArgs e)
330 {
331 if (Enabled && RevertExternalScriptEditorOnExit)
332 {
333 UpdateUnityPreferences(false);
334 }
335 }
File name: ImportTiled2Unity.Mesh.cs
Copy
298 private IList299 {
300 // Report an error for ICustomTiledImporter classes that don't have the CustomTiledImporterAttribute
301 var errorTypes = from a in AppDomain.CurrentDomain.GetAssemblies()
302 from t in a.GetTypes()
303 where typeof(ICustomTiledImporter).IsAssignableFrom(t)
304 where !t.IsAbstract
305 where Attribute.GetCustomAttribute(t, typeof(CustomTiledImporterAttribute)) == null
306 select t;
307 foreach (var t in errorTypes)
308 {
309 Debug.LogError(String.Format("ICustomTiledImporter type '{0}' is missing CustomTiledImporterAttribute", t));
310 }
311
312 // Find all the types with the CustomTiledImporterAttribute, instantiate them, and give them a chance to customize our prefab
313 var types = from a in AppDomain.CurrentDomain.GetAssemblies()
314 from t in a.GetTypes()
315 where typeof(ICustomTiledImporter).IsAssignableFrom(t)
316 where !t.IsAbstract
317 from attr in Attribute.GetCustomAttributes(t, typeof(CustomTiledImporterAttribute))
318 let custom = attr as CustomTiledImporterAttribute
319 orderby custom.Order
320 select t;
321
322 var instances = types.Select(t => (ICustomTiledImporter)Activator.CreateInstance(t));
323 return instances.ToList();
324 }
CurrentDomain 88 lượt xem
Gõ tìm kiếm nhanh...