public static bool Open <T>(SearchWindowContext context, T provider) where T : ScriptableObject, ISearchWindowProvider { // If the window is already open, close it instead. UnityEngine.Object[] wins = Resources.FindObjectsOfTypeAll(typeof(SearchWindow)); if (wins.Length > 0) { try { ((EditorWindow)wins[0]).Close(); return(false); } catch (Exception) { s_FilterWindow = null; } } // We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time. long nowMilliSeconds = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond; bool justClosed = nowMilliSeconds < s_LastClosedTime + 50; if (!justClosed) { if (s_FilterWindow == null) { s_FilterWindow = ScriptableObject.CreateInstance <SearchWindow>(); s_FilterWindow.hideFlags = HideFlags.HideAndDontSave; } s_FilterWindow.Init(context, provider); return(true); } return(false); }
private void Init(SearchWindowContext context, ScriptableObject provider) { this.m_Owner = provider; this.m_Context = context; float num = Math.Max(context.requestedWidth, 240f); float y = Math.Max(context.requestedHeight, 320f); Rect buttonRect = new Rect(context.screenMousePosition.x - num / 2f, context.screenMousePosition.y - 16f, num, 1f); this.CreateSearchTree(); base.ShowAsDropDown(buttonRect, new Vector2(buttonRect.width, y)); base.Focus(); base.wantsMouseMove = true; }
void Init(SearchWindowContext context, ScriptableObject provider) { m_Owner = provider; m_Context = context; float width = Math.Max(context.requestedWidth, k_DefaultWidth); float height = Math.Max(context.requestedHeight, k_DefaultHeight); Rect buttonRect = new Rect(context.screenMousePosition.x - width / 2, context.screenMousePosition.y - k_WindowYOffset, width, 1); CreateSearchTree(); ShowAsDropDown(buttonRect, new Vector2(buttonRect.width, height)); Focus(); wantsMouseMove = true; }
public static bool Open <T>(SearchWindowContext context, T provider) where T : ScriptableObject, ISearchWindowProvider { UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SearchWindow)); bool result; if (array.Length > 0) { try { ((EditorWindow)array[0]).Close(); result = false; return(result); } catch (Exception) { SearchWindow.s_FilterWindow = null; } } long num = DateTime.Now.Ticks / 10000L; if (num >= SearchWindow.s_LastClosedTime + 50L) { if (SearchWindow.s_FilterWindow == null) { SearchWindow.s_FilterWindow = ScriptableObject.CreateInstance <SearchWindow>(); SearchWindow.s_FilterWindow.hideFlags = HideFlags.HideAndDontSave; } SearchWindow.s_FilterWindow.Init(context, provider); result = true; } else { result = false; } return(result); }