PO/Library/Artifacts/6f/6f422b4223b709bf5998d60c90d...

239 lines
13 KiB
Plaintext
Raw Normal View History

2022-01-12 10:06:03 +03:00
<0F>3T2019.4.19f1<00><><EFBFBD><EFBFBD> <00><>f<EFBFBD><66>!<21>5<>9<EFBFBD>4Q<0E><>B<00>7<00><><EFBFBD><EFBFBD><EFBFBD><00><00><00><><00> E<00> <00><00>#<00>.<00>,<00>5a<00> <00><00>#<00>.<00>,<00><00><00>r<00> <00><00># <00>.<00>,
<00>H<00><><00><><EFBFBD><EFBFBD><EFBFBD> <01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00> Q<00>j<00><00><00>J<00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD><00><00><00><00><00>j<00><><EFBFBD><EFBFBD><EFBFBD><00>\<00><00><><EFBFBD><EFBFBD><EFBFBD><00>H<00>r<00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>H<00>w<00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>H<00><><00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>y<00>
<00> <00><00>#!<00>.<00>,"<00><00><><00><><EFBFBD><EFBFBD>#@1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>$<00><00><00>%.<00>j<00>&<00><00><><00><><EFBFBD><EFBFBD>'<00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>(<00><00><00><00>)<00>j<00><><EFBFBD><EFBFBD><EFBFBD>*<00>H<00><><00><><EFBFBD><EFBFBD><EFBFBD>+<00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>,@<00><00><00>-Q<00>j<00>.y<00>
<00> /<00><00>#0<00>.<00>,1<00> <00><>2@<00><00><> 3@<00><00>#4<00>.<00>,5<00>H<00><><00><><EFBFBD><EFBFBD>6<01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>7@<00><00><00>8Q<00>j<00>9H<00><><00><><EFBFBD><EFBFBD>:<01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>;@<00><00><00><Q<00>j<00>=H<00><><00><><EFBFBD><EFBFBD>><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>?@<00><00><00>@Q<00>j<00>AMonoImporterPPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_ExternalObjectsSourceAssetIdentifiertypeassemblynamem_UsedFileIDsm_DefaultReferencesexecutionOrdericonm_UserDatam_AssetBundleNamem_AssetBundleVariants<00><><EFBFBD>G<EFBFBD><47>܏Z56<35>:!@i<>J*<00><00>7<00><><EFBFBD><EFBFBD><EFBFBD><00><00><00><><00>E<00> <00><00><00>.<00><00>(a<00> <00><00><00>.<00><00><00><00>r<00> <00><00> <00>.<00>
<00>H<00><><00><><EFBFBD><EFBFBD><EFBFBD> <01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00> Q<00>j<00>H<00><><00><><EFBFBD><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00><00><00>=<00><><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD><01><00><00><00><00>j<00><><EFBFBD><EFBFBD><EFBFBD><01>H<00><><00><><EFBFBD><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>y<00>
<00> <00><00><00>.<00><00>y<00>Q <00><00><00>.<00> <00><00><00>X!H<00>i<00><><EFBFBD><EFBFBD>"<10>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>#@<00><00><00>$Q<00>j<00>%H<00>u<00><><EFBFBD><EFBFBD>&<10>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>'@<00><00><00>(Q<00>j<00>)PPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_DefaultReferencesm_Iconm_ExecutionOrderm_ClassNamem_Namespace\<00>y<EFBFBD>`<00>"<00>y<EFBFBD>RunModaly"using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.UI
{
[InitializeOnLoad]
internal static class RunModal
{
static RunModal()
{
InitializeInfo();
}
internal static bool IsAvailable()
{
return mShowWithModeMethod != null
&& mCreateSavedGUIState != null
&& mApplyAndForgetMethod != null
&& mParentField != null
&& mParentWindowProp != null
&& mMakeModalMethod != null;
}
internal static void Dialog(EditorWindow window)
{
ShowAsUtility(window);
object savedGUIState = CreateSavedGUIState();
PushDispatcherContext(window);
MakeModal(window);
PopDispatcherContext(window);
ApplySavedGUIState(savedGUIState);
}
static void MakeModal(EditorWindow window)
{
// MakeModal(m_Parent.window);
var hostView = mParentField.GetValue(window);
var parentWindow = mParentWindowProp.GetValue(hostView, null);
mMakeModalMethod.Invoke(
mMakeModalMethod.IsStatic ? null : window,
new object[] { parentWindow });
}
static void ShowAsUtility(EditorWindow window)
{
// ShowWithMode(ShowMode.Utility);
mShowWithModeMethod.Invoke(window, new object[] { 2 });
}
static object CreateSavedGUIState()
{
// SavedGUIState guiState = SavedGUIState.Create();
return mCreateSavedGUIState.Invoke(null, null);
}
static void ApplySavedGUIState(object savedGUIState)
{
// guiState.ApplyAndForget();
mApplyAndForgetMethod.Invoke(savedGUIState, null);
}
static void PopDispatcherContext(EditorWindow window)
{
#if UNITY_2020_1_OR_NEWER
//UnityEngine.UIElements.EventDispatcher.editorDispatcher.PopDispatcherContext();
object editorDispatcher = mEditorDispatcherProp2020.GetValue(null);
mPopContextMethod2020.Invoke(editorDispatcher, null);
#else
// m_Parent.visualTree.panel.dispatcher?.PopDispatcherContext();
object dispatcher = GetDispatcher(window);
if (dispatcher != null)
mPopContextMethod.Invoke(dispatcher, null);
#endif
}
static void PushDispatcherContext(EditorWindow window)
{
#if UNITY_2020_1_OR_NEWER
//UnityEngine.UIElements.EventDispatcher.editorDispatcher.PushDispatcherContext();
object editorDispatcher = mEditorDispatcherProp2020.GetValue(null);
mPushContextMethod2020.Invoke(editorDispatcher, null);
#else
// m_Parent.visualTree.panel.dispatcher?.PushDispatcherContext();
object dispatcher = GetDispatcher(window);
if (dispatcher != null)
mPushContextMethod.Invoke(dispatcher, null);
#endif
}
static object GetDispatcher(EditorWindow window)
{
object dispatcher = null;
if (MayHaveDispatcher())
{
var parent = mParentField.GetValue(window);
if (parent != null)
{
var visualTree = mVisualTreeProp.GetValue(parent, null);
if (visualTree != null)
{
var panel = mPanelProp.GetValue(visualTree, null);
if (panel != null)
{
dispatcher = mDispatcherProp.GetValue(panel, null);
}
}
}
}
return dispatcher;
}
static bool MayHaveDispatcher()
{
return mDispatcherType != null
&& mPushContextMethod != null
&& mPopContextMethod != null;
}
static void InitializeInfo()
{
var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static;
mMakeModalMethod = BuildMakeModalMethodInfo(flags);
mShowWithModeMethod = typeof(EditorWindow).GetMethod("ShowWithMode", flags);
mParentField = typeof(EditorWindow).GetField("m_Parent", flags);
var hostViewType = mParentField.FieldType;
mParentWindowProp = hostViewType.GetProperty("window", flags);
var savedGUIStateType = typeof(EditorWindow).Assembly.GetType("UnityEditor.SavedGUIState");
mCreateSavedGUIState = savedGUIStateType.GetMethod("Create", flags);
mApplyAndForgetMethod = savedGUIStateType.GetMethod("ApplyAndForget", flags);
#if UNITY_2020_1_OR_NEWER
mEditorDispatcherProp2020 = typeof(UnityEngine.UIElements.EventDispatcher).GetProperty("editorDispatcher", flags);
mPushContextMethod2020 = mEditorDispatcherProp2020.PropertyType.GetMethod("PushDispatcherContext", flags);
mPopContextMethod2020 = mEditorDispatcherProp2020.PropertyType.GetMethod("PopDispatcherContext", flags);
#endif
flags = BindingFlags.NonPublic
| BindingFlags.Instance
| BindingFlags.Public;
mParentField = typeof(EditorWindow).GetField("m_Parent", flags);
if (mParentField != null)
hostViewType = mParentField.FieldType;
if (hostViewType != null)
mVisualTreeProp = hostViewType.GetProperty("visualTree");
if (mVisualTreeProp != null)
{
var visualTreeType = mVisualTreeProp.PropertyType;
if (visualTreeType != null)
{
mPanelProp = visualTreeType.GetProperty("panel");
if (mPanelProp != null)
{
var panelType = mPanelProp.PropertyType;
if (panelType != null)
{
mDispatcherProp = panelType.GetProperty("dispatcher");
if (mDispatcherProp != null)
{
mDispatcherType = mDispatcherProp.PropertyType;
if (mDispatcherType != null)
{
mPushContextMethod = mDispatcherType.GetMethod("PushDispatcherContext", flags);
mPopContextMethod = mDispatcherType.GetMethod("PopDispatcherContext", flags);
}
}
}
}
}
}
}
static MethodInfo BuildMakeModalMethodInfo(BindingFlags flags)
{
if (EditorVersion.IsCurrentEditorOlderThan("2019.3.10f1"))
return typeof(EditorWindow).GetMethod("MakeModal", flags);
return typeof(EditorWindow).GetMethod("Internal_MakeModal", flags);
}
static FieldInfo mParentField;
static PropertyInfo mParentWindowProp;
static MethodInfo mMakeModalMethod;
static MethodInfo mShowWithModeMethod;
static MethodInfo mCreateSavedGUIState;
static MethodInfo mApplyAndForgetMethod;
static PropertyInfo mVisualTreeProp;
static Type mDispatcherType;
static MethodInfo mPushContextMethod;
static MethodInfo mPopContextMethod;
static PropertyInfo mPanelProp;
static PropertyInfo mDispatcherProp;
#if UNITY_2020_1_OR_NEWER
static PropertyInfo mEditorDispatcherProp2020;
static MethodInfo mPushContextMethod2020;
static MethodInfo mPopContextMethod2020;
#endif
// // How ContainerWindows are visualized. Used with ContainerWindow.Show
// internal enum ShowMode
// {
// // Show as a normal window with max, min & close buttons.
// NormalWindow = 0,
// // Used for a popup menu. On mac this means light shadow and no titlebar.
// PopupMenu = 1,
// // Utility window - floats above the app. Disappears when app loses focus.
// Utility = 2,
// // Window has no shadow or decorations. Used internally for dragging stuff around.
// NoShadow = 3,
// // The Unity main window. On mac, this is the same as NormalWindow, except window doesn't have a close button.
// MainWindow = 4,
// // Aux windows. The ones that close the moment you move the mouse out of them.
// AuxWindow = 5,
// // Like PopupMenu, but without keyboard focus
// Tooltip = 6
// }
}
}
RunModalUnity.PlasticSCM.Editor.UI