2 using System.Collections.Generic;
 
    4 using System.Reflection;
 
   36             IEnumerable<Type> types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes());
 
   38             Type interfaceType = typeof(T);
 
   39             return types.Where(p => interfaceType.IsAssignableFrom(p) && !p.IsAbstract).ToArray();
 
   47         #region GetMainWindowCenteredPosition 
   55         public static Rect GetEditorWindowCenteredPosition(Vector2 windowSize)
 
   57             Rect mainWindowRect = GetEditorMainWindowPos();
 
   58             return GetCenteredWindowPosition(mainWindowRect, windowSize);
 
   62         private static UnityEngine.Object sMainWindow = 
null;
 
   63         private static Rect GetEditorMainWindowPos()
 
   65             if (sMainWindow == 
null)
 
   67                 var containerWinType = AppDomain.CurrentDomain.GetAllDerivedTypes(typeof(ScriptableObject)).FirstOrDefault(t => t.Name == 
"ContainerWindow");
 
   68                 if (containerWinType == 
null)
 
   69                     throw new MissingMemberException(
"Can't find internal type ContainerWindow. Maybe something has changed inside Unity");
 
   70                 var showModeField = containerWinType.GetField(
"m_ShowMode", BindingFlags.NonPublic | BindingFlags.Instance);
 
   71                 if (showModeField == 
null)
 
   72                     throw new MissingFieldException(
"Can't find internal fields 'm_ShowMode'. Maybe something has changed inside Unity");
 
   73                 var windows = Resources.FindObjectsOfTypeAll(containerWinType);
 
   74                 foreach (var win 
in windows)
 
   76                     int showMode = (int)showModeField.GetValue(win);
 
   85             if (sMainWindow == 
null)
 
   86                 return new Rect(0, 0, 800, 600);
 
   88             var positionProperty = sMainWindow.GetType().GetProperty(
"position", BindingFlags.Public | BindingFlags.Instance);
 
   89             if (positionProperty == 
null)
 
   90                 throw new MissingFieldException(
"Can't find internal fields 'position'. Maybe something has changed inside Unity.");
 
   91             return (Rect)positionProperty.GetValue(sMainWindow, 
null);
 
   94         private static Type[] GetAllDerivedTypes(
this AppDomain aAppDomain, Type aType)
 
   96             return TypeCache.GetTypesDerivedFrom(aType).ToArray();
 
   99         private static Rect GetCenteredWindowPosition(Rect parentWindowPosition, Vector2 size)
 
  104                 width = Mathf.Min(size.x, parentWindowPosition.width * 0.90f),
 
  105                 height = Mathf.Min(size.y, parentWindowPosition.height * 0.90f)
 
  107             float w = (parentWindowPosition.width - pos.width) * 0.5f;
 
  108             float h = (parentWindowPosition.height - pos.height) * 0.5f;
 
  109             pos.x = parentWindowPosition.x + w;
 
  110             pos.y = parentWindowPosition.y + h;
 
  131             string[] s = Application.dataPath.Split(
'/');
 
  132             string projectName = s[s.Length - 2];
 
  149             return Application.platform != RuntimePlatform.WebGLPlayer &&
 
  150                    Application.platform != RuntimePlatform.WSAPlayerARM &&
 
  151                    Application.platform != RuntimePlatform.WSAPlayerX64 &&
 
  152                    Application.platform != RuntimePlatform.WSAPlayerX86 &&
 
  153                    Application.platform != RuntimePlatform.tvOS &&
 
  154                    Application.platform != RuntimePlatform.PS4;
 
  165             #if !UNITY_SAMSUNGTV && !UNITY_TVOS && !UNITY_WEBGL 
  166             if (Path.IsPathRooted(str))
 
  170                     string fullPath = Path.GetFullPath(str);
 
  173                 catch (System.Exception)
 
A collection of useful methods that did not fit into any of the other sections of the asset.
 
static Type[] GetTypeImplementationsNotUnityObject< T >()
Find all implementations of the given parameter type except from those that are a subclass of 'UnityE...
 
static bool IsFilePath(string str)
Determines if the string is file path.
 
static IEnumerable< Type > GetTypeImplementations< T >()
Find all implementations of the given parameter type.
 
static string GetProjectName()
Returns the name of the project
 
static bool IsIOSupported()
Checks if the IO is supported on current platform or not.