No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DockEditorWindow.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Reflection;
  3. using UnityEditor;
  4. namespace Unity.PlasticSCM.Editor.UI
  5. {
  6. internal static class DockEditorWindow
  7. {
  8. static DockEditorWindow()
  9. {
  10. InitializeInfo();
  11. }
  12. internal static bool IsAvailable()
  13. {
  14. return mParentField != null
  15. && mAddTabMethod != null;
  16. }
  17. internal static void To(EditorWindow dockWindow, EditorWindow window)
  18. {
  19. var dockArea = mParentField.GetValue(dockWindow);
  20. mAddTabMethod.Invoke(dockArea, new object[] { window });
  21. }
  22. static void InitializeInfo()
  23. {
  24. var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static;
  25. mParentField = typeof(EditorWindow).GetField("m_Parent", flags);
  26. var dockAreaType = typeof(EditorWindow).Assembly.GetType("UnityEditor.DockArea");
  27. if (dockAreaType == null)
  28. return;
  29. mAddTabMethod = dockAreaType.GetMethod("AddTab", flags,
  30. null, new Type[] { typeof(EditorWindow) }, null);
  31. }
  32. static MethodInfo mAddTabMethod;
  33. static FieldInfo mParentField;
  34. }
  35. }